Jump to content

HELP script won't give inventory on correct answer I am looking my mind!


Zane Veliz
 Share

You are about to reply to a thread that has been inactive for 3632 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Please help me, I have a scavenger hunt event this weekend and this script is not giving the prize for answering the correct answer. I have zero scripting skills so please make it scripting for DUMMIES if you can help. Can someone please help?

 

 

 

list buttons = ["Humans", "Assamite", "Governor", "Zane"];
string dialogInfo = "\nWho are the judges of Caine's children of Abel?";

key ToucherID;
integer dialogChannel;
integer listenHandle;

// copy and paste for the resuls section for wrong answers
// llWhisper(0, "The RiddleBunny smashes your easteregg overtop your head and tells you to try again.");
//for correct answer:
// llGiveInventory(llDetectedKey(0), OBJECTNAME);




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 == "-")
{
llDialog(ToucherID, dialogInfo, buttons, dialogChannel);
return;
}
llListenRemove(listenHandle);
// stop timer since the menu was clicked
llSetTimerEvent(0);
if (message == "Humans")
{
llWhisper(0, "The RiddleBunny smashes your easteregg overtop your head and tells you to try again.");
return;
}
if (message == "Assamite")
{
llGiveInventory(llDetectedKey(0), "zv egg");
}
else if (message == "Governor")
{
llWhisper(0, "The RiddleBunny smashes your easteregg overtop your head and tells you to try again.");
}
else
{
llWhisper(0, "The RiddleBunny smashes your easteregg overtop your head and tells you to try again.");
}
}

timer()
{
// stop timer
llSetTimerEvent(0);

llListenRemove(listenHandle);
llWhisper(0, "Sorry. You snooze; you lose.");
}
}

Link to comment
Share on other sites

always a pleasure...

 

Here's a tighter script. The following changes were made:

  1. Made ToucherID a local variable to the touch_start() event handler. No need to have it global.
  2. Dropped the timer setting down to 10 seconds. A full minute is way too long for such an easy choice.
  3. Reformatted the button choices for a better appearance.
  4. Redid the if() testing in listen(). Just need to check for correct answer, anything else is wrong.

 

  1. list buttons = ["Humans", "Assamite", "Governor", "-", "Zane", "-"];string dialogInfo = "\nWho are the judges of Caine's children of Abel?";integer dialogChannel;integer listenHandle;default{    state_entry()    {        dialogChannel = -1 - (integer)("0x" + llGetSubString( (string)llGetKey(), -7, -1) );    }    touch_start(integer num_detected)    {        key ToucherID = llDetectedKey(0);        llListenRemove(listenHandle);        listenHandle = llListen(dialogChannel, "", ToucherID, "");        llDialog(ToucherID, dialogInfo, buttons, dialogChannel);        llSetTimerEvent(10.0); // Here we set a time limit for responses    }    listen(integer channel, string name, key id, string message)    {        llListenRemove(listenHandle);        // stop timer since the menu was clicked        llSetTimerEvent(0);        if (message == "Assamite")        {            llGiveInventory(id, "zv egg");        }        else        {            llWhisper(0, "The RiddleBunny smashes your easteregg overtop your head and tells you to try again.");        }    }    timer()    {        // stop timer        llSetTimerEvent(0);        llListenRemove(listenHandle);        llWhisper(0, "Sorry. You snooze; you lose.");    }}

     

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3632 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...