Page 1 of 1

How to make a spew only work once.

Posted: Wed Sep 29, 2004 6:43 pm
by Jon the Great
Ok so I made a spew that when activated with a switch would fire a spew.

My problem is that it's possible to hit the switch 10 times and have 10 spews come out.

Here's what I'd like the script to say:

When the player hit's the switch,
check to see if a spew from that object is already going.
IF so, don't turn on spew.
IF NOT, turn on spew.

Any help would be much appreciated.

Posted: Wed Sep 29, 2004 8:33 pm
by Kyouryuu
Seems to me you want to instantiate a timer that lasts the duration of that spew and a bool that is true, but returns to false when the timer expires. So the clause of the switch would go "If player hit switch and bool A is false, then set timer B and set bool A to true." Elsewhere, a second event would go "If timer B has elapsed, set bool A to false."

Posted: Wed Sep 29, 2004 9:48 pm
by Spidey
Iâ??m pretty sure you can set a script to work only onceâ?¦

Under â??actionsâ?

Posted: Thu Sep 30, 2004 5:08 am
by Sirius
Even if not, you can just script in a boolean variable, set it to true when the script is activated, and only initiate the spew if it's false...

Posted: Thu Sep 30, 2004 3:35 pm
by Interceptor6
There are multiple ways to do this, but here is what should be the simplest. Here's what you need to do:

-When the player hit's the switch,
check to see if a spew from that object is already going.

to do this, make a script that has the Owner (switch) with a condition of 'Collided with it'. Next, set the condition as 'if Timer is active' to false with your spew timer as the TimerID.

-IF so, don't turn on spew.

The script won't execute with the above code, since the spewtimer is inactive.


-IF NOT, turn on spew.

Make sure that when the spew is activated, that a timer is set to a time equal to the spew's lifetime. As long as this timer is active, the spew won't be able to turn on.

------

Another way to do this is to set a USERFlag to true whenever the spew is active, and have a timer change it back to false whenever the spew ends. Just set the condition to the 'check' script to 'userflag is false and you are ready to go.

Good luck.

-Int

Posted: Fri Oct 01, 2004 8:53 pm
by Jon the Great
It seems like no matter what I do I'm going to need a timer. How do I set those?

Posted: Fri Oct 01, 2004 10:01 pm
by Kyouryuu
Timers are actually variables you can simply create, just like bools or floats. There are various commands on the timer section of the context menu that you can issue to set the timer, kill the timer, and so forth.

Posted: Sat Oct 02, 2004 4:57 pm
by Jon the Great
It works now! Thanks for all the help. :)
I used the userflag approach.

Posted: Sun Oct 03, 2004 5:26 pm
by Spaceboy
yay more levels