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.
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
|
Interpreter: The interpreter object associated with the event.
Common_Event_ID: The ID number of the common event as defined in the database.
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.
|
|