I am staring a project using a dialog menu and I'm starting with a basic script taken from LSL library. There is a timer event to close the menu after a period of time as well as a Close button. For some reason the menu doesn't close on timeout although the closing message is displayed and the event uses the same line of code as the Close button. It is not crucial to my project but I'd like to know if there is a bug in the script. Here is the script:
list buttons = [ "Green", "Red", "CLOSE", "Yellow"];
string dialogInfo = "\nPlease make a choice.";
key ToucherID;
integer dialogChannel;
integer listenHandle;
default
{
state_entry()
{
dialogChannel = -1 - (integer)("0x" + llGetSubString( (string)llGetKey(), -7, -1) );
}
touch_start(integer num_detected)
{
ToucherID = llDetectedKey(0);
llListenRemove(listenHandle);
listenHandle = llListen(dialogChannel, "", ToucherID, "");
llDialog(ToucherID, dialogInfo, buttons, dialogChannel);
llSetTimerEvent(60.0); // Here we set a time limit for responses
}
listen(integer channel, string name, key id, string message)
{
if (message == "CLOSE")
{
llSetTimerEvent(0);
llListenRemove(listenHandle);
return;
}
llListenRemove(listenHandle);
// stop timer since the menu was clicked
llSetTimerEvent(0);
if (message == "Red")
{
// process Red here
}
else if (message == "Green")
{
// process Green here
}
else
{
// do any other action here
}
}
timer()
{
// stop timer
llSetTimerEvent(0);
llListenRemove(listenHandle);
llWhisper(0, "Sorry. You snooze; you lose.");
}
}