cyber-menace Posted August 20, 2003 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. 0 Share this post Link to post
boris Posted August 20, 2003 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. 0 Share this post Link to post
cyber-menace Posted August 20, 2003 No, I mean once it has activated it will never activate again! That's what I meant. 0 Share this post Link to post
Cyb Posted August 20, 2003 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) 0 Share this post Link to post
The Ultimate DooMer Posted August 20, 2003 Or you could use a sector action thing (eg. Actor enters sector), give it a tid and then remove that thing at the start of the script. 0 Share this post Link to post
Cyb Posted August 20, 2003 I do that all the time and it works just fine, Epyo, maybe you removed the wrong tid? 0 Share this post Link to post
Enjay Posted August 20, 2003 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. :-) 0 Share this post Link to post
Cyb Posted August 20, 2003 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 0 Share this post Link to post