Page 1 of 1

Scripting Question

Posted: Sun Feb 08, 2004 3:42 am
by Black Widow
I created a button that activates something and then deactivates it after 10 secs using a timer. The script executes every time you hit the button, so if you hit the button 4 times the scipt is also running 4 times. How do I make the script execute only once, and then enable it to execute again?

Posted: Sun Feb 08, 2004 4:52 am
by Atan
// i.e //

create a user flag, name it 'tRun'

at your level start event
Set user Flag 'tRun' to FALSE

Now:

Script xx0 'Hit Button'

-> Owner 'Button' (Object)

Event: Collided (with IT)

? if the following condition is met:
AND
+ ? (IT is a player or player weapon) = TRUE
+ ? (User Flag 'tRun')= FALSE

> Then perform the following actions:
Play object OWNER animation from 0-x, .... sound etc
Set user flag 'tRun' to TRUE
Generate object OWNER timer event in 10.00 seconds with ID 'mytime'
DO NOTHING


next script:

Script xx1 'mytime' timer off

-> Owner 'Button' (Object)

Event: Timer (TIMER ID)

? If the following condition is met:
+ ? (mytime)=(TIMER ID)

> Then perform the following actions:
..do your stuff
Set user Flag 'tRun' to FALSE
DO NOTHING


//--
This means that if you hit your button,
the script is looking if your flag is set or not,
if not it starts action and set the Flag now.

If you hit your button again (during the timer is running),
the script will jump over your action
until your timer is off.

In the timer off script yout 'tRun' flag is set to false again
and the next hit will trigger your action again.

I hope this example is understandable.

Posted: Sun Feb 08, 2004 5:33 am
by Black Widow
It works!
Thanks for your help!

Posted: Sun Feb 08, 2004 11:13 am
by Kyouryuu
I'm pretty certain there's also an option for every event that says "Trigger Only Once" or something along those lines. I'm not sure where they put it - possibly on a right-click context menu?

Posted: Sun Feb 08, 2004 11:43 am
by Atan
Yes it's inside.
right click on :Then perform following action.
But it does what it says: Execute only once then,
behind this, the script is not executed anymore up to next level start. Correct me if I'm wrong with this idea.

Posted: Sun Feb 08, 2004 7:56 pm
by Interceptor6
just add a 'timer is active' condition with FALSE in your conditions for the script that initiates the timer. You don't really need a user flag, but it will work that either way.

Posted: Mon Feb 09, 2004 11:10 am
by Atan
this would save resources, nice!!
But I can't find this 'timer is active' condition in the moment,
where must I exactly look for it?
could you please give an short example?
TIA

Posted: Mon Feb 09, 2004 5:39 pm
by Interceptor6
I'm not totally sure where it is, but if I remember correctly this is what you should do:

Under conditions, select default comparison statement.

Right click the first parameter in the statement, and select replace with query. It may be under timer, misc or something like that.

I don't remeber exactly where it is, but I'm pretty sure it is in there somewhere. It certainly saves some time not having to set up user flags.

Hope that helps.

Posted: Tue Feb 10, 2004 7:19 am
by Black Widow
Next question: How do you make a specific weapon shake the level when it hits a wall?

Posted: Tue Feb 10, 2004 7:59 pm
by Interceptor6
I think it has to have a gravity field. Just set gravity time to zero and gravity size to zero so there won't actually be a gravity field. You should see a lot of sparks when the missile hits the wall, and it should shake the level slightly. Something like that was used my schplurg when he made the Earthshaker 2001. It seemed to shake the wall somewhat when the big missile collided with a wall. I've never tested it, but that would be my best guess.

Good luck.

-Int

Posted: Wed Feb 11, 2004 9:02 am
by Black Widow
I want it to shake a bit more like in D2

Posted: Sun Feb 15, 2004 1:27 am
by Interceptor6
Well, I really doubt there is a way to get it to shake any more than it does, with just Gamtool at least. Since you cannot script to an individual weapon in dallas, there isn't really a way to affect the level of shake.Which really is a bummer, since the Earthshaker really should shake things up quite a bit more. Not much that can be done about it though.