deactivating scripts after running once

Non-platform specific questions.

deactivating scripts after running once

Postby mal99 » Mon Jun 27, 2011 8:56 pm

I want to run two separate scripts initiated by 'mouse button down' events on the same actor. One script must run repeatedly, after each 'mouse button down', the other must run just once. So, I need a way to de-activate the run-once script after the first mouse button down.

Is there a simple way to do this?

I tried putting the whole script in a 'for loop' with a one cycle limit but, so far, this just succeeded in crashing the whole game.

Any ideas would be much appreciated.

Thanks
mal99
 
Posts: 10
Joined: Tue May 31, 2011 11:47 pm
Score: 0 Give a positive score

Re: deactivating scripts after running once

Postby foleyjo » Mon Jun 27, 2011 9:01 pm

When I do something like this I use an integer Variable called ACTIVE

So when you want to start the script make a statement saying script.ACTIVE = 1;

In the script itself start with

If (ACTIVE){

and at the end of the if put
ACTIVE = 0;}

I assume you are doing this in the Draw Actor event otherwise you could do an On Mouse Click action and not repeat
KISS -Keep It Simple Stoopid
foleyjo
 
Posts: 275
Joined: Mon Jul 09, 2007 1:15 pm
Score: 15 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest