Posts: 1,664
Threads: 391
Joined: May 2009
Heya, is there a way I could obtain the ID to "This common event"?
Y'know how map events have @event_id? Is there something like that for common events?
Posts: 627
Threads: 38
Joined: May 2009
$data_common_events[common_event_id]
I think. Don't hold me to that. I'm still learning.
My partner in crime = TREXRELL
Posts: 1,664
Threads: 391
Joined: May 2009
Doesn't work. ;_;
*doesn't hold Yin to it*
Posts: 11,231
Threads: 649
Joined: May 2009
Obtain??
Common Events are called by map events are generally parallel processes. I mean you may be able to 'pass' the id of a common event into a script call to run an event (if you're good enough), but I never heard of one needing to retrieve the ID of a common event itself.
You could set up an event in each common event:
CONTROL VARIABLES[0001: Event-ID] set = '1'
or whatever for each common event.
Then when the common event is run, it changes that one variable (#1) to that value. Then within the script, you can access that through $game_variables.
Posts: 627
Threads: 38
Joined: May 2009
Oops.
Sorry.
My partner in crime = TREXRELL
Posts: 112
Threads: 26
Joined: May 2009
That's evil punk.
You should tell when you get a solution.
Here is an XP solution where I overwrite setup_starting_event rather than alias it because the other way will be computationally more intensive.
Yes, the structure is not set up to allow the id of the running common event to be retrieved easily >_<
Code:
class Game_CommonEvent
alias :zeriab_interpreter_id_refresh :refresh
def refresh
zeriab_interpreter_id_refresh
@interpreter.common_event_id = @common_event_id unless @interpreter.nil?
end
end
class Interpreter
attr_writer :common_event_id
def common_event_id
@common_event_id = 0 if @common_event_id.nil?
@common_event_id
end
#--------------------------------------------------------------------------
# * Call Common Event
#--------------------------------------------------------------------------
alias :zeriab_common_id_command_117 :command_117
def command_117
zeriab_common_id_command_117
if $data_common_events[@parameters[0]] != nil
@child_interpreter.common_event_id = @parameters[0]
end
true
end
#--------------------------------------------------------------------------
# * Starting Event Setup
#--------------------------------------------------------------------------
def setup_starting_event
# Refresh map if necessary
if $game_map.need_refresh
$game_map.refresh
end
# If common event call is reserved
if $game_temp.common_event_id > 0
# Set up event
setup($data_common_events[$game_temp.common_event_id].list, 0)
## Added
self.common_event_id = $game_temp.common_event_id
# Release reservation
$game_temp.common_event_id = 0
return
end
# Loop (map events)
for event in $game_map.events.values
# If running event is found
if event.starting
# If not auto run
if event.trigger < 3
# Clear starting flag
event.clear_starting
# Lock
event.lock
end
# Set up event
setup(event.list, event.id)
return
end
end
# Loop (common events)
for common_event in $data_common_events.compact
# If trigger is auto run, and condition switch is ON
if common_event.trigger == 1 and
$game_switches[common_event.switch_id] == true
# Set up event
setup(common_event.list, 0)
## Added
self.common_event_id = common_event.id
return
end
end
end
end
*hugs*