So I'm lucky most days to make a working script that says 'Hello Avatar!', hence I defer to y'all..
I understand that most scripters hate the llSleep command. In the following example script, could anyone suggest some better way to perform the multiple pauses in the execution of this script?
(of course this is not a real script, and yes it is an endless loop as written, but it would be in a temp rez object so i'm not really concerned about the endless bit)
Thanks All!
-----------------------
integer on;
default
{
state_entry()
{
llSetTimerEvent(.05);
}
timer()
{
llPerform-Some-Function();
llSleep (.03);
llPerform-Some-Function();
llSleep (.03);
llPerform-Some-Function();
llSleep (.03);
llPerform-Some-Function();
llSleep (.03);
llPerform-Some-Function();
llSleep (.03);
llPerform-Some-Function();
llSleep (.03);
llPerform-Some-Function();
llSleep (.03);
llPerform-Some-Function();
llSleep (.03);
llPerform-Some-Function();
llSleep (.03);
llPerform-Some-Function();
llSleep (.03);
llPerform-Some-Function();
llSleep (.03);
llPerform-Some-Function();
llSleep (.03);
llPerform-Some-Function();
llSleep (.03);
llPerform-Some-Function();
}
}
Trouble llSleeping - advise please
- Shandon Loring
- Posts: 1377
- Joined: Sat Oct 26, 2013 3:25 am
- Has thanked: 1032 times
- Been thanked: 1624 times
- Contact:
Trouble llSleeping - advise please
Last edited by Shandon Loring on Sun Jan 22, 2023 7:01 am, edited 1 time in total.
- These users thanked the author Shandon Loring for the post:
- Christine Nyn
- Ilan Tochner
- Posts: 6726
- Joined: Sun Dec 23, 2012 8:44 am
- Has thanked: 5247 times
- Been thanked: 4674 times
- Contact:
Re: Attn: llSleep Haters - advise please
Hi Shandon,
llsleep should be avoided because it can prevent other scripts from being run. See: http://opensimulator.org/pipermail/open ... 10792.html
llsleep should be avoided because it can prevent other scripts from being run. See: http://opensimulator.org/pipermail/open ... 10792.html
- These users thanked the author Ilan Tochner for the post (total 3):
- Shandon Loring • Christine Nyn • Selby Evans
- Shandon Loring
- Posts: 1377
- Joined: Sat Oct 26, 2013 3:25 am
- Has thanked: 1032 times
- Been thanked: 1624 times
- Contact:
Re: Attn: llSleep Haters - advise please
Thank you Ilan,
Like Nicky Perian in the article you reference, more what I'm asking is a suggested way to rewrite the example script I provided.
Anyone?
Thanks all!

Like Nicky Perian in the article you reference, more what I'm asking is a suggested way to rewrite the example script I provided.
Anyone?
Thanks all!

- These users thanked the author Shandon Loring for the post (total 2):
- Ilan Tochner • Christine Nyn
-
- Posts: 1314
- Joined: Sun Dec 23, 2012 2:26 pm
- Has thanked: 1134 times
- Been thanked: 1142 times
Re: Trouble llSleeping - advise please
I'm an intermediate-level scripter at best but I think the following does what you specified using llOwnerSay instead of llPerform etc. It also avoids continuous operation.
Code: Select all
integer LOOP = 0;
integer MAX = 14;
default
{
state_entry()
{
if (LOOP == 0)
{
llSetTimerEvent(0.5);
}
else if (LOOP < MAX)
{
llSetTimerEvent(0.03);
}
else
{
llSetTimerEvent(0.0);
}
}
timer()
{
state doLoop;
}
}
state doLoop
{
state_entry()
{
llOwnerSay(">>"+(string)LOOP);
LOOP++;
state default;
}
}
- These users thanked the author Graham Mills for the post (total 3):
- Ilan Tochner • Christine Nyn • Shandon Loring
- Christine Nyn
- Posts: 84
- Joined: Sat Mar 07, 2020 10:20 pm
- Has thanked: 273 times
- Been thanked: 153 times
Re: Trouble llSleeping - advise please
Using the timer event as Graham has done is the way to go when restructuring a script to avoid the use of llSleep. The only downside to that is that you couldn't get the 0.03 delay you put in your original example since the shortest interval available on a Kitely timer is 0.5 seconds (or was when last I checked).
The main reason for avoiding llSleep is that OpenSim doesn't have many threads running simultaneously to handle all the scripts that are running on a region and llSleep() simply hangs on to a thread while doing absolutely nothing. The timer event gives back the thread to the general pool until the timer fires. This has the effect that if several scripts are running which are using llSleep they can starve all other scripts in the region of the chance to run, effectively bringing everything to a halt.
The main reason for avoiding llSleep is that OpenSim doesn't have many threads running simultaneously to handle all the scripts that are running on a region and llSleep() simply hangs on to a thread while doing absolutely nothing. The timer event gives back the thread to the general pool until the timer fires. This has the effect that if several scripts are running which are using llSleep they can starve all other scripts in the region of the chance to run, effectively bringing everything to a halt.
- These users thanked the author Christine Nyn for the post (total 4):
- Ilan Tochner • Shandon Loring • Graham Mills • Selby Evans
- Shandon Loring
- Posts: 1377
- Joined: Sat Oct 26, 2013 3:25 am
- Has thanked: 1032 times
- Been thanked: 1624 times
- Contact:
Re: Trouble llSleeping - advise please
Thank you all for insight and advice!
- These users thanked the author Shandon Loring for the post:
- Graham Mills