Jump to content
Sign in to follow this  
4ntifa

Script instances

Recommended Posts

If unit X has activated a trigger, which runs a script, what happens if unit Y then also activates the trigger while the previously launched script is still running? Does another instance of the script begin running, totally independent of the one already running? Or does the previous script terminate and then run again, from the beginning? Or something else?

Share this post


Link to post
Share on other sites

I've had multiple instances of the same script running, without any problems. Just keep your vars local.

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Gaswell @ Jan. 05 2002,15:41)</td></tr><tr><td id="QUOTE">I've had multiple instances of the same script running, without any problems. Just keep your vars local.<span id='postcolor'>

This whole local/global stuff is pretty much undocumented. How does it work? Prefixing varnames with an _underscore makes a variable local, right? So, without it, it's global? And a global variable would be "visible" to other instances or even totally different scripts?

Share this post


Link to post
Share on other sites

Yes, it's like in any programming language;

A local variable in a script exist only when the host script is called. Once the script terminates, the local variables gets removed, thus losing their data.

A global variable on the other hand is alwayes there, and can be checked from outside a script (if it's located in a script). You can have a global variable in script A that's being checked in script B, and so on. They're known and stored by the "world" (meaning everyone knows about it).

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×