Submit Your Article RPG RPG Revolution RPG Maker VX.com
 
RPG Maker
 

 Username:
 Password:
   Not a member? Register!



Home > RGSS Script Reference > Game_CommonEvent

Game_CommonEvent


Inherits from: None

Description: This class holds the information for common events, such as the list of event commands, its trigger, and its trigger switch. This class also holds the code for running parallel process common events.

Code


class Game_CommonEvent
# ------------------------------------  
  def initialize(common_event_id)
    @common_event_id = common_event_id
    @interpreter = nil
    refresh
  end
# ------------------------------------  
  def name
    return $data_common_events[@common_event_id].name
  end
# ------------------------------------  
  def trigger
    return $data_common_events[@common_event_id].trigger
  end
# ------------------------------------  
  def switch_id
    return $data_common_events[@common_event_id].switch_id
  end
# ------------------------------------  
  def list
    return $data_common_events[@common_event_id].list
  end
# ------------------------------------  
  def refresh
    if self.trigger == 2 and $game_switches[self.switch_id] == true
      if @interpreter == nil
        @interpreter = Interpreter.new
      end
    else
      @interpreter = nil
    end
  end
# ------------------------------------
  def update
    if @interpreter != nil
      unless @interpreter.running?
        @interpreter.setup(self.list, 0)
      end
      @interpreter.update
    end
  end
end

Properties


Interpreter: The interpreter object associated with the event.

Common_Event_ID: The ID number of the common event as defined in the database.

Methods


Initialize

Arguments: None
Local Variables: None

How it Works: Sets the common event ID value to the ID number of the event as defined in the database, and initializes the @interpreter to a nil object.

Name

Arguments: None
Local Variables: None

How it Works: Returns the name of the common event as defined in the database.

Trigger

Arguments: None
Local Variables: None

How it Works: Returns the trigger of the common event (0 = Call, 1 = Auto-Start, 2 = Parallel Process).

Switch_ID

Arguments: None
Local Variables: None

How it Works: Returns the trigger switch of the common event. If the event has a trigger of "Call", this value is 0.

List

Arguments: None
Local Variables: None

How it Works: Returns the list of event commands for this common event.

Refresh

Arguments: None
Local Variables: None

How it Works: This method manages common events with the "Parallel Process" trigger. If the common event's trigger is 2 and the trigger switch is true (on), the method checks to see if the event has finished executing or hasn't started (@interpreter == nil). If either of these cases is true, the method creates a new interpreter object. Otherwise, it does nothing.

Update

Arguments: None
Local Variables: None

How it Works: This method updates the event's state each frame. If the interpreter object exists and isn't nil, it checks to see if the interpreter is running. If it isn't, the Interpreter#Setup method is called, which starts the event running at the first event command in its list. Then, the Interpreter#Update method is called to do update processing that is shared by both map events and common events. 
Syntax
@
@@
$
alias
[array index]
attr_accessor
attr_reader
attr_writer
class
def
do
ensure
for
if
[iterator]
key => value
new
next
nil
redo
require
return
rescue
self
super
undef
unless
until
while
yield

Classes
Arrow_Actor
Arrow_Base
Arrow_Enemy
Game_Actor
Game_Actors
Game_BattleAct
Game_Battler
Game_Character
Game_Common
Game_Enemy
Game_Event
Game_Map
Game_Party
Game_Picture
Game_Player
Game_Screen
Game_SlfSwitch
Game_Switches
Game_System
Game_Troop
Game_Variables
Interpreter
Scene_Debug
Scene_End
Scene_Equip
Scene_File
Scene_Gameover
Scene_Item
Scene_Load
Scene_Map
Scene_Menu
Scene_Name
Scene_Save
Scene_Shop
Scene_Skill
Scene_Status
Scene_Title
Sprite_Battler
Sprite_Character
Sprite_Picture
Sprite_Timer
Spriteset_Battle
Spriteset_Map
Window_Base
Window_Battleresult
Window_Battlestatus
Window_Command
Window_DebugLeft
Window_DebugRight
Window_EquipItem
Window_EquipLeft
Window_EquipRight
Window_Gold
Window_Help
Window_InputNumb
Window_Item
Window_MenuStatus
Window_Message
Window_NameEdit
Window_NameInput
Window_PartyCom
Window_PlayTime
Window_SaveFile
Window_Selectable
Window_ShopBuy
Window_ShopCom
Window_ShopNum
Window_ShopSell
Window_ShopStatus
Window_Skill
Window_SkillStatus
Window_Status
Window_Steps
Window_Target

Other
Class Hierarchy
Global Variables


RPG RPG Revolution
RPG RPG Revolution is your #1 stop for game development and console RPG games, as well as those created by people like you. Link to us to support us, so we may grow to be better website community for you.

RPG RPG Revolution is an Privacy Policy and Legal