The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: shintashi on March 06, 2011, 05:38:01 AM

Title: [RESOLVED] how do you call a common event with script?
Post by: shintashi on March 06, 2011, 05:38:01 AM
this is probably a snippet request.

I'm currently testing

p $data_common_events[1].name


with success, but I haven't figured out how to actually trigger the event yet. Somehow I think the answer is in this mess,


  def command_117
    # Get common event
    common_event = $data_common_events[@parameters[0]]
    # If common event is valid
    if common_event != nil
      # Make child interpreter
      @child_interpreter = Interpreter.new(@depth + 1)
      @child_interpreter.setup(common_event.list, @event_id)
    end
    # Continue
    return true
  end


but I'm not sure which parts to keep and which parts to throw out.
Title: Re: how do you call a common event with script?
Post by: shintashi on March 06, 2011, 05:21:02 PM
$game_temp.common_event_id = 1

This works at least for script in regular events, but it does not do anything when called during the script editor from a class. I recognize the 'A" or "C" button is essentially activating it in events, so that the common even is activated by pushing space bar, talking to the event, etc., but I have yet to figure out the code that is connecting the snippet above to my keyboard actions. Literally, my "make it so" command is not working.
Title: Re: [REQUEST] how do you call a common event with script?
Post by: shintashi on March 06, 2011, 05:49:29 PM
so far I've able to determine the script that works inside a regular event, to call a common event, does not work inside something like

if Input.trigger?(32) #spacebar
$game_temp.common_event_id = 1
end


Although something like this


if Input.trigger?(32) #spacebar
    p $data_common_events[1].name
end


works fine, in determining the label of the common event. That's kind of odd because as I've said before, in eventing,

$game_temp.common_event_id = 1


Runs common event #1 efficiently and effectively, as if I had called it using stock eventing commands.
Title: Re: [REQUEST] how do you call a common event with script?
Post by: shintashi on March 08, 2011, 03:28:25 PM
I found this on the interwebs

   1. # If On Map : Replace id with common event id
   2. $game_temp.common_event_id = id
   3. # If in Battle : Replace id with common event id
   4. common_event = $data_common_events[id]
   5. $game_system.battle_interpreter.setup(common_event.list, 0)


line 2 definitely looks like what I came up with, and lines 4 & 5 look new, so i'll test those later today, but I've got classes in a few minutes so it will have to wait.  :-[
Title: Re: [REQUEST] how do you call a common event with script?
Post by: shintashi on March 09, 2011, 02:11:42 AM
ive checked it and it appears lines 4 and 5 work