Aaron Levy
Medicated Lately?
Join date: 3 Jun 2004
Posts: 2,147
|
07-12-2004 11:15
I need to pause my script while I wait for input from one of my objects buttons.
Should I do this using a do-while loop, and as long as the listen even hasn't received one of the two inputs it accepts, keep waiting? Or is there a better way to do this?
|
Moopf Murray
Moopfmerising
Join date: 7 Jan 2004
Posts: 2,448
|
07-12-2004 12:43
If you use a loop you'll never recieve the listen event as the current block (the do while) will keep on running, blocking the listen event being fired. Depending on the situation, just doing nothing, and executing the rest of the code in the listen event may be the way to go.
|
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
|
07-12-2004 13:01
LSL is an event driven language. What this means is that a script is always  sitting there doing nothing until an event happens. When something happens, the event-handler for that thing is called, it runs and then the script goes back to doing nothing. So, when you compile a script, something happens right away, the "state_entry" event handler is called to handle that, and you want that to finish and the script to get back to busily doing nothing so that it will be ready to process the text it hears in its listen event handler.  except when it's handling an event I hope this un-confuses you more than it confuses you.
_____________________
Sarcasm meter: 0 |-----------------------*-| 10 Rating: Awww Jeeze!
|
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
|
07-12-2004 13:23
Ah, but on re-reading your post, it seems like you want your script to not handle other events until it hears a certian something. What you want is a new state! Something like: default { state_entry { llDialog(...); } listen(...) { if (something) { state active; } } }
state active { /* do stuff */ }
_____________________
Sarcasm meter: 0 |-----------------------*-| 10 Rating: Awww Jeeze!
|
Aaron Levy
Medicated Lately?
Join date: 3 Jun 2004
Posts: 2,147
|
07-12-2004 13:31
Yeah, the script essentially needs to freeze until it gets input; I'll play around with your snippet and see what I come up with. I can't believe how much I accomplished in the past 24 hours with everyone's help here.
|
Aaron Levy
Medicated Lately?
Join date: 3 Jun 2004
Posts: 2,147
|
07-12-2004 16:21
Phht... I'm a dunce. I just can't get a grasp of the concept, and the script just keeps giving me syntax errors in that spot.
I've changed my original approach to listen for a linked mesasge from another prim in the group, could that be it?
|
Siggy Romulus
DILLIGAF
Join date: 22 Sep 2003
Posts: 5,711
|
07-12-2004 21:09
Nope , Wednesday's approach is very sound.
Break up your code into different states. I'm at work and can't write example code atm....
But the concept is pretty simple when you get into it.. Imagine a door in SL -- a door could easily have 2 states, Open and Close...
Your script set your door as Open, wait for input, the change state to Closed.
Your closed state would do the same. set the door closed and wait for input before changing state to Open.
Thats the simplist way I can think of to explain it....
Siggy.
_____________________
The Second Life forums are living proof as to why it's illegal for people to have sex with farm animals. From: Jesse Linden I, for one, am highly un-helped by this thread
|