Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Event queuing

Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
09-09-2007 00:34
default
{
touch_start(integer total_number)
{
llSay(0, "Touched.";);
llSleep(1.0);
}
}

Now click on that a few times quickly. What would you expect? I thought the script had an event queue that would hold up to 64 events, so I'd expect it to say "Touched" once a second, for as many times as I clicked on it. What I see, makes it look like the script receives no events while it's in the llSleep call. I saw the same thing with an llInstantMessage in place of the llSay and no llSleep. So it looks like, when a script is blocked, it doesn't queue up any events.

Maybe it's always been this way, and I've never noticed it? I thought events got queued up, and you'd only lose events if you get past 64 to any individual script.
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
09-09-2007 00:56
My understanding is that when a script 'sleeps' it is dead to the world. Events don't register at all, therefore nothing is cued. But, the cue works when... say running a lengthy user-function, and someone clicks during the function... once the function clears, the click is registered and processed.

The sleep = dead to the world is useful for times you may want a script to ignore everything for a while. Say, a collision detector in a goal which needs to register one, and only one collision event with a ball... but the ball might spam several collisions if left alone. So, you llSleep() the script for a few seconds after the collision, to allow time to kill the ball.

I imagine llInstantMessage() has a built-in penalty sleep which works the same as llSleep().
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
09-09-2007 01:44
Not a perfect explanation but... says:
From: LSL Wiki ScriptDelay


"When a script is being delayed, the event queue still fills, but in a rather peculiar manner:

...touch_start/touch_end it is only executed once after the delay."
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
09-09-2007 07:01
More specifically:

From: someone

Puts the script to sleep for sec seconds. During this time, the current event will not be exited, no other events will be processed.
(As a comment notes, new events are still queued, but it looks like only one event of each type will actually queue while the script sleeps(/delays?). Anyone know more about that?)
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
09-09-2007 08:00
Using tough_start as a test may not be the what you want in this case, since, in theory, rapid sequential touches may not trigger multiple events even without a sleep. Instead, they are added to the total_number parameter, and you are expected to process them one by one yourself. (While this seems rare, and usually you can get away with llDetectedKey(0), multiple touches could require a for loop, and llDetectedKey(1), for instance, to process all the touches).
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
09-09-2007 09:29
I doubt I was clicking fast enough to get multiple hits in the same touch_start. And it registered for each touch fine without the llSleep.

So either touch happens only once, or I only get one event per type. I guess I should have checked the Wiki first :) I could test this with a timer I guess and see what pattern that follows.
Lear Cale
wordy bugger
Join date: 22 Aug 2007
Posts: 3,569
09-09-2007 10:34
A simple test of mine seems to show that it behaves as described in the Wiki. I used a long sleep, and touching it any number of times after the first touch causes it to enter the touch handler exactly once after the sleep. The count was always one.

CODE

default
{
state_entry()
{
llSay(0, "Hello, Avatar!");
}

touch_start(integer total_number)
{
llSay(0, "Touched " + (string)total_number);
llSleep(10);
llSay(0, "sleep done");
}
}