Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Newbie dialog/give notecard question

June Juneau
Registered User
Join date: 3 Jan 2007
Posts: 1
01-16-2007 11:44
Hey all, I'm a total blond when it comes to scripting but i copy/pasted two together in the hope it would show a dialog with 8 items and then give the selected option as a notecard....

Somehow... it doesn't

Hope anyone can point me out where I pasted wrong :)

integer CHANNEL = 42;
list MENU_MAIN = ["Event1", "Event2", "Event3", "Event4","Event5", "Event6", "Event7", "Schedule"]; // the main menu

default {
state_entry() {
llListen(CHANNEL, "", NULL_KEY, "";);
}

touch_start(integer total_number)
{
llDialog(llDetectedKey(0), "What do you want to know?", MENU_MAIN, CHANNEL);
}

listen(integer channel, string name, key id, string message)
{
if (llListFindList(MENU_MAIN, [message]) != -1)
{
llSay(0, name + " picked the option '" + message + "'.";);
if (message == "Schedule";)
llGiveInventory(llDetectedKey(0), "Schedule";);
else if (message == "Event1";)
llGiveInventory(llDetectedKey(0), "Event1";);
else if (message == "Event2";)
llGiveInventory(llDetectedKey(0), "Event2";);
else if (message == "Event3";)
llGiveInventory(llDetectedKey(0), "Event3";);
else if (message == "Event4";)
llGiveInventory(llDetectedKey(0), "Event4";);
else if (message == "Event5";)
llGiveInventory(llDetectedKey(0), "Event5";);
else if (message == "Event6";)
llGiveInventory(llDetectedKey(0), "Event6";);
else if (message == "Event7";)
llGiveInventory(llDetectedKey(0), "Event7";);
else if (message == "...Back";)
llDialog(id, "What do you want to know?", MENU_MAIN, CHANNEL);
} else
llSay(0, name + " picked invalid option '" + llToLower(message) + "'.";);
}
}


I got the items in the contents. If I don't i get a script error saying it's not there when i touch the option, but somehow i don't get the notecard...
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
01-16-2007 12:13
I think the problems the llDetectedKey(0)

It's fine in the touch_start Event but doesn't exist in the listen Event. However, you're in luck :) as the listen Event passes the name and the key of the speaker (or clicker of the Dialog), so 'id' should be good to go in llGiveInventory
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-16-2007 13:04
Pale pipped me to the post on that one.

Something else to be aware of is that names are case sensitive so "Event7" and "event7" are different.

I also noticed that you have a BACK option in the listen that isnt in the MENU code?

Since your notecard names exactly match your Dialog entries you could rewrite the listen as follows

CODE


listen(integer channel, string name, key id, string message)
{
if("...Back" == message)
{
llDialog(id, "What do you want to know?", MENU_MAIN, CHANNEL);
}
else if (llListFindList(MENU_MAIN, [message]) != -1)
{
llSay(0, name + " picked the option '" + message + "'.");
llGiveInventory(id, message);
}
else
{
llSay(0, name + " picked invalid option '" + llToLower(message) + "'.");
}
}



You could also expand that idea to help in popualting your menu list dynamically using the llGetInventoryNumber and llGetInventoryName functions.