Call common event before every map event activation?

● ARCHIVED · READ-ONLY
Started by Geoff Moore 20 posts View original ↗
  1. I'd like a common event to run whenever the player activates a map event, directly before the event itself. I know I could go into every separate event to trigger it, but is there a way to make a general rule with code instead?

    Thanks for reading!
  2. What do you mean "whenever the player activates a map event" exactly?
  3. Whenever the player uses the action button for an action button event, touches a player touch event, or triggers an autorun event.
  4. Put this in your script editor and replace ID with the id of the event you want to call..

    Code:
    class Game_Event  alias :start_comevv :start  def start(*args)    $game_temp.reserve_common_event( ID )    start_comevv(*args)  endend
  5. Hmm, that hangs the game. (I put it in a new script in Materials, is that right?)

    Is the script applying to EVERY event, including common events? If it is, then I guess the common event I want to run is calling itself, causing an endless loop? So I just need it to run on events on the map, if possible.
  6. Yea just under materials and above main.

    Thats a strange one.. It only applies to the Game_Events. Game_CommonEvent is a diffferent thing altogether.. Maybe I'm overlooking something :/
  7. What are you trying to accomplish? What's so special about the common event you want to run?
  8. yea thats a very good question..

    If its just to something simple it could be much easier to script and then it wouldnt require the common event :p
  9. Sorry for the delay, sleep and work happened. Here's the event, it just stops any character animations that are taking place:

    screen.jpg
  10. Alright then ...

    1. If the player is facing down, you don't need to TELL them to turn down - they're ALREADY facing down.

    2. You're asking for a script that lets you call a common event that then does script calls. Uh-huh.

    3. Do this:

    Code:
    class Game_Event  alias :start_comevv :start  def start(*args)    if trigger_in?([0,1,2])      $game_player.set_char("$bugwalk",1,2,2)      $game_player.restore_char    end    start_comevv(*args)  endend
    So if any event is triggered by action button, player touch or event touch, Galv's (?) script calls will be executed before the event starts.
  11. Extra points to Shaz for guessing the script that the calls are from (assuming of course that she is (edit:) right )
  12. Oh, sorry, I should have explained that! It's Galv's Move Route Extras. The reason the player turns in their current direction before the graphic changes is because my animations are using up/down/left/right frames of character graphics, so that will need to go in there. I can totally see why it seemed redundant, I should have explained myself better. Also, should the script read: $game_player.restore_char?
  13. yes. Typo. sorry.

    I still don't see why you want to turn them in a direction they're already facing. Your condition says "if the player is facing left, then make them turn left". But if they're facing left, they are ALREADY turned left.

    Try it the way I posted (with the typo fixed), and if you STILL think they need to turn to face the direction they're already facing (and I REALLY don't think they do), add the extra line as shown:

    Code:
    class Game_Event  alias :start_comevv :start  def start(*args)    if trigger_in?([0,1,2])      $game_player.set_direction($game_player.direction)      $game_player.set_char("$bugwalk",1,2,2)      $game_player.restore_char    end    start_comevv(*args)  endend
  14. @Shaz - to make them face left-er ?
  15. Dekita said:
    @Shaz - to make them face left-er ?
  16. ... ... ... these go to eleven...
  17. Yes, because sometimes you just can't face left enough.


    I don't think it's necessary, but the OP seems adamant, so I figured I'd provide it now, just in case they proved me wrong and I had to provide it later anyway :)
  18. Nah, can never face too left. The more the better imo...
    Could maybe enhance the method so that it turns left, turns right, then turns left again - just to show that left is better ^_^
  19. IT'S STILL NOT LEFT ENOUGH!! j/k

    I am such a moron...

    However, I do still need the branching as the code currently turns my character down regardless of which direction they were facing. The last 2 of $game_player.set_char("$bugwalk",1,2,2) denotes the direction row of the character sheet, 2 for down, 4 for left, 6 for right and 8 for up.
  20. We'll get there :)

    Code:
    class Game_Event  alias :start_comevv :start  def start(*args)    if trigger_in?([0,1,2])      $game_player.set_direction($game_player.direction)      $game_player.set_char("$bugwalk",1,2,$game_player.direction)      $game_player.restore_char    end    start_comevv(*args)  endend
    And maybe THAT means you can remove the set_direction command.