|
Iris Bourdeille
Registered User
Join date: 12 Jul 2006
Posts: 59
|
05-08-2007 16:16
i'm tryin got make a simple loop that allows me to interupt it at any stage. My touch_start however doesn't seem to get recognized at all. Can anybody help integer x = 5;
default { state_entry() { if(x>1) { x=x-1; state default; } if(x==1) { state climb; } } touch_start(integer total_number) { state interupt; } } state interupt // this part disrupts the loop { touch_start(integer total_number) { if(x>1) { state default; } if(x<5) { state climb; } } } state climb { state_entry() { if(x<5) { x=x+1; state climb; } if(x==5) { state default; } } touch_start(integer total_number) { state interupt; } }
|
|
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
|
05-08-2007 17:10
FYI, if your target state on a state change is the same as the current state, state_entry and state_exit do not re-happen.
|
|
Sys Slade
Registered User
Join date: 15 Feb 2007
Posts: 626
|
05-08-2007 17:47
IIRC, events aren't triggered inside loops either.
_____________________
Send me the last 4 digits of a valid SSN, I'll verify you are who you say you are, even if you aren't.
|
|
Iris Bourdeille
Registered User
Join date: 12 Jul 2006
Posts: 59
|
05-08-2007 18:02
From: Sys Slade IIRC, events aren't triggered inside loops either. So not matter what i do i cannot interupt a loop ? unless i go in an manually break the script. a touch start, a listen or a link message cannot do anything to effect the loop , because those events will never fire.
|
|
Ed Gobo
ed44's alt
Join date: 20 Jun 2006
Posts: 220
|
05-08-2007 18:23
Rather than have long loops, better to use timerEvent calls with variables to track what you are doing on each timer event. Timer events persist across state changes so be careful there.
That also allows touches to be accepted and actioned at almost any time.
Use llOwnerSay () statements to indicate what state you in!
|
|
Darius Lehane
Registered User
Join date: 18 Apr 2005
Posts: 180
|
05-08-2007 18:35
I had a problem where a script I was working on didn't respond to touch, or show the touch cursor (the finger/hand cursor) or touch in the radial menu for the prim. So I cut-and-paste the script text to another script in my inventory, deleted the offending script from the prim, and replaced it with the inventory script. Viola! It worked again.
The problem might be an SL glitch, try this solution.
|
|
Stavros Augustus
Registered User
Join date: 14 Nov 2005
Posts: 38
|
05-08-2007 19:28
loopBreak(integer x, integer loopVar) { //x is boolean, loopVar is the current loop value if(x) { if(1==1) { //Hack to allow state changes within user functions state interrupt; return; //exit the function } } for(loopstuff) { if(gDoInterrupt) { //make this true on touch_start gDoInterrupt = FALSE; Loop(TRUE, loopVar); //recursive call to change the state return; //exit } } }
I think that should work.
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
05-09-2007 00:41
From: Iris Bourdeille So not matter what i do i cannot interupt a loop ? unless i go in an manually break the script. a touch start, a listen or a link message cannot do anything to effect the loop , because those events will never fire. LSL is monotonic, i.e. only one event can be processed at a time, Any other events that are triggered are added to the pending queue. Since your code is only exiting by state change then none of them can be processed. As Ed suggested use a timer to give the other events a chance to be processed.
_____________________
I'm back......
|