Jump to content
Sign in to follow this  
Brackev

Calling a common event from a script

Recommended Posts

@your_variable = Game_CommonEvent.new(common_event_id)

That should work

 

PS : I don't wanna be that guy but a little 'hi' is always welcome

Edited by Riff

Share this post


Link to post
Share on other sites
@your_variable = Game_CommonEvent.new(common_event_id)

That should work

 

PS : I don't wanna be that guy but a little 'hi' is always welcome

 

i try that and it's not executing. did i miss some steps?

 

for calling common event i usually use:

$game_temp.reserve_common_event(id)

the common event will be executed in Scene_Map / Scene_Battle / Scene that have interpreter... so if called in scene without interpreter it will wait and executed when entering scene with interpreter.

 

another method is using Tsukihime Scene Interpreter script

   @interpreter.setup($data_common_events[id].list)

the common event will be executed immediately in that scene.

Edited by estriole

Share this post


Link to post
Share on other sites

 

@your_variable = Game_CommonEvent.new(common_event_id)
That should work

 

PS : I don't wanna be that guy but a little 'hi' is always welcome

 

You should reserve the common event. The engine will figure out how to best execute it.

 

I couldn't get it to work either, but I imagine it may or may not work depending on whether you're lucky or not.

Edited by Tsukihime

Share this post


Link to post
Share on other sites

@estriole && @Tsukihime

 

Right, I'm sorry I didn't take into account the cases where you're not in Scene_Map (thus it was working fine for me x))

 

PS : there was another problem with this call, if your common event was supposed to be updated, then it wouldn't because it wasn't added to the comment event list)

Share this post


Link to post
Share on other sites

Strange  :huh:  I tried with a play animation command and it worked... Maybe the script I'm working on is interfering.

Share this post


Link to post
Share on other sites

Hmm..  I'm not much of a coder.  I copied the def for the level up procedure and made my own script in materials.  I am trying to call a common script up whenever someone levels.  Which one of these would work for me?

Share this post


Link to post
Share on other sites

Find the source of the problem, use Tsukihime's (a piece of advice : always use Tsukihime's) as mine won't work alone (it worked in my test project because of another script)

Share this post


Link to post
Share on other sites

Ok.  I dropped in Tsukihime Scene Interpreter above the script I'm calling the Common Event from.  Still doesn't work.  Here's more info about what I'm doing.  Below is a pic of the common event I'm trying to run.  Below that is the script I'm trying to call it from.  I still feel like I'm missing something obvious.  Make it easy on me Please. 

  #--------------------------------------------------------------------------
  # * Level Up
  #--------------------------------------------------------------------------
  def level_up
    @level += 1
    self.class.learnings.each do |learning|
      learn_skill(learning.skill_id) if learning.level == @level
    end
    @your_variable = Game_CommonEvent.new(001)
  end

Share this post


Link to post
Share on other sites

if you already install Tsukihime Scene Interpreter.

try this snippet maybe:

class Scene_Base
  def interpreter
    @interpreter
  end
end
class Game_Actor < Game_Battler
  alias com_ev_level_up level_up
  def level_up
  com_ev_level_up
  SceneManager.scene.interpreter.setup($data_common_events[1].list)
  end
end

it will execute common event 1 when level up

 

btw what do you want to do with common event in level up?. do all character call the same common event? if yes then above already ok. but if you want each actor call another common event need some notetags code to support that (or simple case code based on @actor_id might be ok too).

Edited by estriole

Share this post


Link to post
Share on other sites

ah yes.

replacing

SceneManager.scene.interpreter.setup($data_common_events[1].list)

with

$game_temp.reserve_common_event(1)

could also work

 

i just prefer first option because i have encounter problem with second one before (with tsuki scene_interpreter installed). but i forget what problem.

Edited by estriole

Share this post


Link to post
Share on other sites

I am only working with one common event right now. 

The system I want is for each actor to only have 3 special skills available to them at any one point.  So as they get a better version of each special, I want to get rid of the old version.  Think Fire 1, Fire 2, Fire 3, but only having the best version available at any time.  I also have Yanfly's battle system tied in so that only the specials are available as commands.  There is no basic attack, but the specials cost no mp/tp, so it balances in that respect.

The common event checks to see if you have a better version of each skill and removes the old if you have it.  One script will check each of the 3 main charactors on an individual basis.  I looked at the skill replacer script on here but couldn't figure out how to make it work for me in this situation. 

 

@Estriole I put the script in and the first way works.  I'm adding you to the special thanks list.

Edited by Brackev

Share this post


Link to post
Share on other sites

Multiple reserved common events?

Yeah i think that's what make me use the first code. since before the first common event in reserved executed. second common event already replaced what reserved. thus first common event skipped... but i forget the detail either. :D.

 

@brackev: glad that it work out :D.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted