Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Break out of while loop for listen event?

Synergy Belvedere
Prim Reaper
Join date: 7 Jul 2004
Posts: 253
04-04-2005 09:08
I want the listen event to fire during a while loop that's in my state_entry(), but apparently it wont let it.

CODE

integer Stop = FALSE;
default
{
state_entry()
{

ears=llListen(9999,"",NULL_KEY,"");
while(Stop == FALSE)
{
//do stuff
// want the listen event to fire in this loop
}
}
listen(integer chan, string name, key id, string msg)
{
Stop=TRUE;
}
}


Any ideas?
Adam Zaius
Deus
Join date: 9 Jan 2004
Posts: 1,483
04-04-2005 09:29
A timer is probably a good way of handling this kind of function. :)

-Adam
_____________________
Co-Founder / Lead Developer
GigasSecondServer
Kali Dougall
Purple and Spikey
Join date: 5 Feb 2005
Posts: 98
04-04-2005 09:33
Yes, you have to use a timer for that. While any event/function is active and running, additional events just queue up behind it. So your listen event is waiting for the while statement to be done before it fires.
Synergy Belvedere
Prim Reaper
Join date: 7 Jul 2004
Posts: 253
04-04-2005 09:34
Ty Adam, I actually tried that.

What's happening in the While loop is a prim is getting stretched on its Z axis. It's basically a power meter that goes from 0 to 2.0 M and then back to 0 and starts the process over. Since the minimum time for timer events seems to be .1 seconds, the prim grows really jerkily (is that a word?). The while loop allows a very smooth scale on the prim.
CrystalShard Foo
1+1=10
Join date: 6 Feb 2004
Posts: 682
04-04-2005 09:59
This is where llSetScriptState() might come handy.

Not positive if this will work for scripts that are "stuck" in a loop, but try:

Script 1: Listens for incoming listener event. Turns the second script on and off as needed.
Script 2: Constant scale change loop.
Talila Liu
Micro Builder
Join date: 29 Jan 2004
Posts: 132
04-04-2005 11:06
Like crystal said use 2 scripts and if you want to run the loop again reset it later useing:
CODE
llResetOtherScript();


If your object figured out power for a gauge or something like that, you could get the scale of the prim to get that value.
Synergy Belvedere
Prim Reaper
Join date: 7 Jul 2004
Posts: 253
04-04-2005 11:15
Thanks folks, just gonna use the timer event and not fuss with it anymore lol

Thanks again!
-Syn