Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Strange behaviour in llSleep

Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
09-24-2007 00:33
ok, a little oddness I've encountered today with timing and llSleep

script_number is assumed to be from 1 -10

llMessageLinked( integer sender, integer number, string some_string, key some_key ){
if (number == some_preset){
llSleep( script_number / 10 );
state next_state;
}}

in the next state a llSetLinkParams call is made....

everything works except that it seemed to be running a lil fast (actually simultaneous), so I changed sleep to script_number / 5

and here's the weirdness... the first five scripts fire simultaneously, and then after a delay, the next five.....

EDIT!!!
ok so the realization struck me that if it's splitting at around .5 it must be because it's rounding... oops DUH.... script_number is defined as a integer, so it was returning an integer.... simple fix

llSleep( (float)script_number / 10.0 );

I think it's time for this call llSleep( Void ).........
Malachi Petunia
Gentle Miscreant
Join date: 21 Sep 2003
Posts: 3,414
09-24-2007 00:58
You've not posted enough information for me to answer your question, but I can tell you two things that may help.

1) llSleep() is a BLOCKING call, the script does nothing else while in a sleep, events pending for that script are queued until some small limit. A corollary to this is you should *never* block in an event handler.

2) the granularity of llSleep is higher than you might expect. You can request a sleep of 0.0005 seconds, but don't expect it to be that short. I think that llSleep promises at least as long a delay as you request but nothing more.

Good luck.