Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
cyber-menace

1 Time Only Script

Recommended Posts

How do I make a script activate only once even if it is activated at different times by different triggers?

EDIT: 250 POSTS! Now I can use my own avatar. Phew, that took quite awhile.

Share this post


Link to post

ACS_Execute will only allow one instance of the script to run at a time.
ACS_ExecuteAlways allows more than one instance of the script to run at a time.

Share this post


Link to post

int scr01 = 0;
script 1 (void)
{
   if(!scr01)
   {
      //do stuff here
      scr01 = 1;
   }
}
that's about the most simple way, a more elegant way (I suppose) would be to give all the switches a lineid (via setlineid();) and then in an open script set their special (with setlinespecial();, they'd all have the same lineid and the same specials) and then do this:
script 1 (void)
{
   //do stuff
   setlinespecial(1, 0);
}
which would set all the lines with lineid 1 to have special 0 (which is nothing)

Share this post


Link to post

I do that all the time and it works just fine, Epyo, maybe you removed the wrong tid?

Share this post


Link to post
Cyb said:

a more elegant way (I suppose) would be to give all the switches a lineid (via setlineid();) and then in an open script set their special (with setlinespecial();



Elegant? Heh, I've been doing it that way for ages. I assumed it was a clunky "mechanical" way to do it. The reason I did it that way was I didn't really understand variables, so simply "switching off" the lines by changing their special was a surefire way for me to understand and know what was going on in my level. I didn't realise I was being elegant. :-)

Share this post


Link to post

well it's all a matter of opinion I guess, using less vars is generally better than using them (less memory) plus if you clear the line then the switch can't be hit again. with the if(!scr01) method you can still hit the switch after you've used it the first time it's just that nothing happens. Actually, that's not true since it still runs the script and does comparison to check if scr01 is 0 (taking a couple extra cpu cycles, albeit not noticable to most if not all computers), so yeah, the clear line way is more elegant :) though it takes a bit more effort

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×