How to make a spew only work once.

For Descent, Descent II and Descent3 level editing and modification assistance.
Post Reply
User avatar
Jon the Great
DBB Captain
DBB Captain
Posts: 538
Joined: Fri Nov 28, 2003 3:01 am
Location: California

How to make a spew only work once.

Post 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.
User avatar
Kyouryuu
DBB Alumni
DBB Alumni
Posts: 5775
Joined: Fri Apr 30, 1999 2:01 am
Location: Isla Nublar
Contact:

Post 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."
User avatar
Spidey
DBB Grand Master
DBB Grand Master
Posts: 10807
Joined: Thu Jun 28, 2001 2:01 am
Location: Earth

Post by Spidey »

Iâ??m pretty sure you can set a script to work only onceâ?¦

Under â??actionsâ?
User avatar
Sirius
DBB Master
DBB Master
Posts: 5616
Joined: Fri May 28, 1999 2:01 am
Location: Bellevue, WA
Contact:

Post 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...
User avatar
Interceptor6
DBB Ace
DBB Ace
Posts: 138
Joined: Sat Mar 01, 2003 3:01 am
Location: baton rouge, LA, USA

Post 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
User avatar
Jon the Great
DBB Captain
DBB Captain
Posts: 538
Joined: Fri Nov 28, 2003 3:01 am
Location: California

Post by Jon the Great »

It seems like no matter what I do I'm going to need a timer. How do I set those?
User avatar
Kyouryuu
DBB Alumni
DBB Alumni
Posts: 5775
Joined: Fri Apr 30, 1999 2:01 am
Location: Isla Nublar
Contact:

Post 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.
User avatar
Jon the Great
DBB Captain
DBB Captain
Posts: 538
Joined: Fri Nov 28, 2003 3:01 am
Location: California

Post by Jon the Great »

It works now! Thanks for all the help. :)
I used the userflag approach.
User avatar
Spaceboy
DBB Captain
DBB Captain
Posts: 603
Joined: Sat Oct 02, 2004 11:43 pm
Contact:

Post by Spaceboy »

yay more levels
Post Reply