Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

First Touch ignored on state change

Gruff Grut
Registered User
Join date: 13 Jun 2008
Posts: 7
02-05-2009 16:50
OK Guys and Gals, can someone explain this little teaser that I never noticed berfore - here is a tiny script tp show what I mean - you touch it changes states then sleeps for 2 seconds before returning to default state. At this point, the next time it is touched it is ignored, touch again and it goes to the other state. I can get around it by uncommenting the touch_start in the second state but ....... I wonder why it happens? Anybody got an explanation?
default
{
state_entry()
{
llSay(0, "default";);
}

touch_start(integer total_number)
{
llSay(0, "Touched.";);
state waitabit;
}
}

state waitabit
{
state_entry()
{
llSay(0, "waitabit";);
llSleep(2.0);
state default;
}
// touch_start(integer total_number)
// {
// }
}
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
02-05-2009 17:00
LLSleep means your script is cueing some events but is not going to do anything until it wakes up and you have it going back to state default as soon as that happens.

Try it like this and you can see that the touch events are processed in both states:

CODE

default {
touch_start(integer total_number) {
llSay(0, "state default");
state waitabit;
}
}

state waitabit {
touch_start(integer total_number) {
llSay(0, "state waitabit");
state default;
}
}
_____________________
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
Destiny Niles
Registered User
Join date: 23 Aug 2006
Posts: 949
02-05-2009 17:07
To keep you 2 second wait intack use llSetEventTimer

CODE

default {
touch_start(integer total_number) {
llSay(0, "state default");
state waitabit;
}
}

state waitabit {
touch_start(integer total_number) {
llSay(0, "state waitabit");
llSetTimerEvent(2);
}
timer()
{
state default;
}

}
Gruff Grut
Registered User
Join date: 13 Jun 2008
Posts: 7
ref the second state
02-05-2009 17:12
The sleep is only in the second state to make it wait a bit - imagine that replaced by some sort of processing; the question is, why on returning to default does the first touch in the default state not register? There is no 'useful' touch in the second state, the commented one - totally empty, somehow makes the first touch work on returning to default(when it is uncommented of course)
Lazink Maeterlinck
Registered User
Join date: 8 Nov 2005
Posts: 332
02-05-2009 17:39
I know exactly what your talking about. I have a script that changes state on an inventory change (soft reset), and I know it goes into that state because the floating text change, but I have to touch the item twice in order for it to read the notecard again. I don't know why it does this, but just letting you know, you are not alone in noticing this behavior.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
02-05-2009 17:48
Your script is working fine for me if I wait until it says "default", which is the expected behavior.
_____________________
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
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
02-05-2009 22:13
yep, sounds like you're just not waiting long enough. 2 seconds doesn't seem like a long time, but when you're watching closely, and also with lag sometimes that time can seem longer than you think it should be. i have a 50 face texture display with a page function. each time it changes pages it has to go thru and re-texture each face seperately which gives a 0.2 second delay. i actually took a stop watch to test how much time it took. it should have taken right on 10 seconds, but my stopwatch got to 20 before it finished texturing
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
02-05-2009 23:13
For me the script works exactly as the OP stated.
If you do not have a touch_start() in state waitabit you have to touch twice after returning in state default.
If there is a empty touch_start() you only need to touch once.

It's a known bug:
http://jira.secondlife.com/browse/SVC-3017
Debbie Trilling
Our Lady of Peenemünde
Join date: 17 Oct 2006
Posts: 434
02-06-2009 01:54
I have come across this too and it was driving me nutz.

Never did get to the bottom of it properly, but, IIRC I substitued the 'touch_start' event with a 'touch' event and it all seemed fine. Obviously this will not be suitable for all situations.

From: Ron Khondji


Thanks, voted.
_____________________
http://wiki.secondlife.com/wiki/User:debbie_Trilling
Gruff Grut
Registered User
Join date: 13 Jun 2008
Posts: 7
Known Bug
02-06-2009 02:51
Ok folks thanks for all that - known bug - found it and voted
--- thanks to the ppl who didn't get all hot and bothered about the sleep statement lol -
as i say adding an empty touch_start to the 'second state' is a workaround or as Debbie says a 'touch' rather than 'touch start' in default works (I've not checked this but I trust her implicitly)