|
Robertt Goodliffe
Registered User
Join date: 1 Jan 2006
Posts: 16
|
09-10-2006 15:10
Below is an example of a Script using llDialoge. Can someone please alter this code to show me how I would allow the USER only 20 Seconds to choose his/her answer. If he/she hasnt clicked a button within 20 seconds a message must be sent on channel 0 saying 'I am sorry but you have taken too long to answer!" and if he/she subsequently presses a button after 20 seconds it is completly ignored. Thanking you in advance integer CHANNEL = 42; list MENU_MAIN = ["Sit", "Stand", "Fly", "Cheat", "Options..."]; default { state_entry() { llListen(CHANNEL, "", NULL_KEY, ""  ; } touch_start(integer total_number) { llDialog(llDetectedKey(0), "What do you want to do?", MENU_MAIN, CHANNEL); } listen(integer channel, string name, key id, string message) { if (llListFindList(MENU_MAIN + MENU_OPTIONS, [message]) != -1) { llSay(0, name + " picked the option '" + message + "'."  ; } else llSay(0, name + " picked invalid option '" + llToLower(message) + "'."  ; } }
|
|
Lazink Maeterlinck
Registered User
Join date: 8 Nov 2005
Posts: 332
|
09-10-2006 15:26
integer CHANNEL = 42; list MENU_MAIN = ["Sit", "Stand", "Fly", "Cheat", "Options..."]; integer LISTENER;
default
{ state_entry() { //Remove this line and put it in the touch state llListen(CHANNEL, "", NULL_KEY, ""); }
touch_start(integer total_number) { LISTENER = llListen(CHANNEL, "", NULL_KEY, ""); //Opens the listener llDialog(llDetectedKey(0), "What do you want to do?", MENU_MAIN, CHANNEL); llSetTimerEvent(20); //Add Timer to your dialog }
listen(integer channel, string name, key id, string message) { if (llListFindList(MENU_MAIN + MENU_OPTIONS, [message]) != -1) { llSay(0, name + " picked the option '" + message + "'."); } else { llSay(0, name + " picked invalid option '" + llToLower(message) + "'."); } llListenRemove(LISTENER); //Closes the listener llSetTimerEvent(0); //makes sure the timer doesn't fire when not ment to }
//If the timer fires, the person has taken to long timer() { llSay(0, "I am sorry but you have taken too long to answer!" llListenRemove(LISTENER); llSetTimerEvent(0); //Stops the timer from repeating } }
Think that is what you need, I added in the timer event to controlt he dialog, hope that helps 
|
|
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
|
09-10-2006 15:29
integer listen_handle;
default {
touch_start(integer total_number) {
listen_handle = llListen(CHANNEL, "", llDetectedKey(0), ""); llDialog( ... ); llSetTimerEvent( 20.0 ); }
timer(
if( listen_handle ) {
llListenRemove( listen_handle ); listen_handle = 0; llSay( 0, "Time's up, yo!" ); } }
listen(integer channel, string name, key id, string message) { // handle input here } }
|
|
Robertt Goodliffe
Registered User
Join date: 1 Jan 2006
Posts: 16
|
Thankyou Lazink
09-10-2006 15:48
Thanks Lazink that is exactly what I needed and it works like a charm. Cheers!!!!
|