Aaron Levy
Medicated Lately?
Join date: 3 Jun 2004
Posts: 2,147
|
07-22-2004 13:54
Is there a way to pause for input without using states? I started writing my script, not taking states into consideration and would like to finish this script without revamping the whole thing. I just need to pause the script four times and wait for the user to push a button, which will then whisper the button pressed (for simplicity sake).
thanks, al
|
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
|
07-22-2004 15:57
States are really the way to go if you want to do this. Refactoring shouldnt be too hard, but I understand how you feel. However, I dont have a solution for you  ==Chris
|
Aaron Levy
Medicated Lately?
Join date: 3 Jun 2004
Posts: 2,147
|
07-22-2004 18:39
Bleh... not what I wanted to hear, but what I was expecting, nonetheless.
So how would I use states to do this?
Do I create a state for each question posed to the user, and then a state for each answer they could give, either true or false?
|
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
|
07-23-2004 00:05
From: someone Originally posted by Aaron Levy Bleh... not what I wanted to hear, but what I was expecting, nonetheless.
So how would I use states to do this?
Do I create a state for each question posed to the user, and then a state for each answer they could give, either true or false? Oh! So you have something like this: string BUTTON_TRUE = "True"; string BUTTON_FALSE = "False";
list QUESTIONS = [ "Are you alive?", "Are you human?" ];
integer QUESTION_COUNT = 2;
integer DIALOG_CHANNEL = 385834;
key myUser = NULL_KEY; integer curQuestion = 0;
displayQuestion() { llDialog(myUser, llList2String(QUESTIONS, curQuestion), [BUTTON_TRUE, BUTTON_FALSE], DIALOG_CHANNEL); }
// Waiting for a user: default { touch_start(integer totalNumber) { myUser = llDetectedKey(0); state asking; } }
// Asking questions to a user: state asking { state_entry() { // Listen for dialog responces. llListen(DIALOG_CHANNEL, "", myUser, ""); displayQuestion(); }
listen(integer channel, string name, key id, string message) { if (message == BUTTON_TRUE) { // Handle TRUE. } else { // Handle FALSE. }
curQuestion++; if (curQuestion >= QUESTION_COUNT) { // No more questions left. state default; } else { displayQuestion(); } } state_exit() { curQuestion = 0; } }
|