Jump to content


Event_perform - How Does It Work?

  • This topic is locked This topic is locked
1 reply to this topic

#1 Game_boy


    GMC Member

  • New Member
  • 265 posts

Posted 23 December 2007 - 08:17 PM

Despite reading the help file, I am confused about how event_perform and similar functions work; I am concerned it will cause unexpected behaviour if used in my game.

Originally, I wanted a turn-based battle system with a single main code loop. Unfortunately, this made it hard to make other objects move and interact as it was stuck in the loop and screen_redraw was erratic.

I changed it to several sections of code, each in a user-defined event: one section executes, then some time later other sections are called using event_user and event_perform_object from different scripts.

I read that event_perform 'snaps back' to the first code after the called event is finished, and also that variable declarations apply to the first code, not the called instance's code.

Since I have several layers of calling, does this have the potential to cause pseudorandom behaviour with variables and ordering?

If so, can you suggest how I can cleanly snap from one event to another?
  • 0

#2 Smarty


    GMC Member

  • GMC Elder
  • 7522 posts
  • Version:GM:Studio

Posted 24 December 2007 - 12:34 AM

Calling the user event works just like calling scripts (except that you can't give it parameters in that way, and that they don't return results). Just as with scripts, if you want to keep some variables local to the current script, you should define them in that script using var.
  • 0