Page 1 of 1

Timer end on script, can be done?

PostPosted: Mon Jul 26, 2010 5:10 pm
by FERdeBOER
My question of the day is this: is it possible to make a script including the end of a timer?

I mean: I would like to create a script which includes an action when the timer ends.
I know there's the TIMER option, but I wonder if It can be putted all in the same "package".

Something like this:
Code: Select all
if(landing==1)
{
   CreateTimer("Event Actor", "takeoff", 2000);
   and here some kind of if(takeofftimer==0)
                         {
                             CreateActor....
                         }
}


Is there a way for doing this?

Thank you very much.

Re: Timer end on script, can be done?

PostPosted: Mon Jul 26, 2010 5:42 pm
by Bee-Ant
FERdeBOER wrote:is it possible to make a script including the end of a timer?

Possible.


For instance you want to check your character's type by timer.

Player -> CreateActor -> ScriptEditor:
Code: Select all
type=rand(100);
CreateTimer("Event Actor","CheckType",100);


Timer -> "CheckType" -> ScriptEditor:
Code: Select all
if(type==0)
{
   //do something 1
}
if(type==1)
{
    //do something 2
}
//etc

Re: Timer end on script, can be done?

PostPosted: Mon Jul 26, 2010 7:35 pm
by FERdeBOER
Thank you for your fast reply.
Question: why do you randomize with rand(100)?

Re: Timer end on script, can be done?

PostPosted: Mon Jul 26, 2010 10:35 pm
by FERdeBOER
Now I look twice your code... it implies using Timer -> "CheckType" -> ScriptEditor
I'm asking if it's possible to avoid doing this, including the action when the timer ends on the same script where it has been created.

Re: Timer end on script, can be done?

PostPosted: Tue Jul 27, 2010 4:32 am
by Bee-Ant
FERdeBOER wrote:Thank you for your fast reply.
Question: why do you randomize with rand(100)?

It's just an example...you don't need to use ran() anyway...

FERdeBOER wrote:Now I look twice your code... it implies using Timer -> "CheckType" -> ScriptEditor
I'm asking if it's possible to avoid doing this, including the action when the timer ends on the same script where it has been created.

No...
All the codes in one section, will be executed at one time.
So if you want to suspend it by Timers, you have to use Timer event. CAN'T avoid it :D

Re: Timer end on script, can be done?

PostPosted: Tue Jul 27, 2010 4:38 am
by Bee-Ant
EXCEPT, you want to suspend it by variables, you don't need Timer usage...
For example, you want to make your Player's health to be increased at certain timing, so...

Player -> Draw Actor -> Script Editor :
Code: Select all
int count;
count+=1;
if(count>=100)
{
    health+=10;
    count=0; //reset the count
}

In that code, your player's health will be increased only if count equal to 100.
And remember, this can only be done in Draw Actor, you can't use this method on any other event...
Hope helps :D

Re: Timer end on script, can be done?

PostPosted: Tue Jul 27, 2010 11:11 am
by FERdeBOER
Thank you very much!

Ok, so I must use Timer... :mrgreen: