Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

how to call the same function again

Dominique Laville
Registered User
Join date: 24 Apr 2008
Posts: 84
07-27-2009 02:26
hi,

Can I use setTimerEvent and timer outside the default {} field ?

I ask this because I have 2 scripts in the same object, and I need to set a timer not in the main script.

thanks
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
07-27-2009 03:11
(All scripts need a default state.)

A timer event is local to the script (although global to all states within that script). If multiple scripts need to know about expiry of a single timer, the script with that timer needs to llMessageLinked(LINK_THIS...) the other scripts, which will learn about it with link_message() events.
Dominique Laville
Registered User
Join date: 24 Apr 2008
Posts: 84
07-27-2009 03:13
ok thanks
Dominique Laville
Registered User
Join date: 24 Apr 2008
Posts: 84
07-27-2009 05:04
one more thing..

how can I stop the timer once it is started ??

thanks
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
07-27-2009 05:54
llSetTimerEvent (0.0) will stop it...
_____________________
Sick of sims locking up every time somebody TPs in? Vote for SVC-3895!!!
- Go here: https://jira.secondlife.com/browse/SVC-3895
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
07-27-2009 10:46
note that if a timer is already queued (say you have a fast timer, and/or another event is still running when the timer SHOULD fire) the timer event will still fire one extra time after you set it to zero in those conditions. to prevent this extra firing you can use a check variable that is also set to false when the timer is set to zero, and enclose your code from the timer in an if statement that checks your variable...

eg
CODE

// in your globals
float active;

//wherever you trigger your timer use
llSetTimerEvent( active = # );
// where # is your timer interval or zero

timer(){
if (active){
//do code
}
}
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -