Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

need help with menu script

Belladonna DuCasse
Registered User
Join date: 26 Jan 2007
Posts: 29
05-21-2007 04:37
Grr! I'm going nuts ...
I cant script for the life of me but I have figured how to mod one to suit my needs.
The project I am working on now needs a menu script (to give food) which I have found and modded. I get the three menus to come up so I can make a choice BUT the object will no longer give me the item I chose from the menu. What have I done and how can I fix it?
I'd actually prefer for the object I choose to rez on the table in front of me instead of ending up in my inventory, is this possible with this script I have?

Below is the script I am playing with. I'd sure appreciate your help :)

list Menu = ["Burger", "Sandwich", "Slice of Lasagana"]; // menu Text
list Items = ["Burger", "Sandwich", "Slice of Lasagana"];// Inventory object names
list Menu2 = ["Beer", "Cup of Tea", "Island Rum", "Jack and Coke", "Ice Cold Milk", "Coffee/Milk", "Soda Water", "Corona", "Cocoa", "Glass of Champagne"]; // menu Text
list Items2 = ["Beer", "Cup of Tea", "Island Rum", "Jack and Coke", "Ice Cold Milk", "Coffee/Milk", "Soda Water", "Corona", "Cocoa", "Glass of Champagne"];// Inventory object names
list Menu3 = ["Apple Slice", "Birthday Cake", "Cheese/Fruit Plate", "Chocolate Cookies", "Choc Strawberries"]; // menu Text
list Items3 = ["Apple Slice", "Birthday Cake", "Cheese/Fruit Plate", "Chocolate Cookies", "Choc Strawberries"];// Inventory object names
integer handle;
default
{
touch_start(integer num)
{
key id = llDetectedKey(0);
handle = llListen(45, "", id, "";);
llDialog(id, "What Would You Like To Eat?", Menu, 45);
llDialog(id, "What would you like to drink?", Menu2, 45);
llDialog(id, "What would you like for desert?", Menu3, 45);
llSetTimerEvent(30);
}
listen(integer channel, string name, key id, string message)
{
llListenRemove(handle);
llSetTimerEvent(0);
integer index = llListFindList(Menu, [ message]);
if(index >= 0) llGiveInventory(id, llList2String(Items, index));
}
timer()
{
llListenRemove(handle);
llSetTimerEvent(0);
llWhisper(0, "Menu timeout.";);
}
}
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
05-21-2007 04:43
You never start a listen.

In answer to your request to rez rather than putting it in inventory take a look at llRezObject
_____________________
I'm back......
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
Newgy was bored....
05-21-2007 04:59
Personally I'm against hard coded channels for dialogs unless there is a good reason for it but I've left this one in place. I also hate having multiple dialogs flash up so I've added a top level menu.

You may want to take a look at the Refridgerator thread.

CODE

list Menu = [ "Food","Drink","Desert"];
list FoodMenu = ["Burger", "Sandwich", "Slice of Lasagana"]; // menu Text
list FoodItems = ["Burger", "Sandwich", "Slice of Lasagana"];// Inventory object names
list DrinkMenu = ["Beer", "Cup of Tea", "Island Rum", "Jack and Coke", "Ice Cold Milk", "Coffee/Milk", "Soda Water", "Corona", "Cocoa", "Glass of Champagne"]; // menu Text
list DrinkItems = ["Beer", "Cup of Tea", "Island Rum", "Jack and Coke", "Ice Cold Milk", "Coffee/Milk", "Soda Water", "Corona", "Cocoa", "Glass of Champagne"];// Inventory object names
list DesertMenu = ["Apple Slice", "Birthday Cake", "Cheese/Fruit Plate", "Chocolate Cookies", "Choc Strawberries"]; // menu Text
list DesertItems = ["Apple Slice", "Birthday Cake", "Cheese/Fruit Plate", "Chocolate Cookies", "Choc Strawberries"];// Inventory object names
integer handle;
integer Channel = 45;

CancelListen()
{
llListenRemove(handle);
llSetTimerEvent(0);
}

default
{
touch_start(integer num)
{
key id = llDetectedKey(0);
handle = llListen(45, "", id, "");
llDialog(id, "What Would You Like?", Menu, Channel);
}
listen(integer channel, string name, key id, string message)
{
CancelListen();
integer index = llListFindList(Menu, [ message]);
if(index >= 0)
{
if(0 == index) llDialog(id, "What Would You Like To Eat?", FoodMenu, Channel);
else if(1 == index) llDialog(id, "What would you like to drink?", DrinkMenu, Channel);
else if(2 == index) llDialog(id, "What would you like for desert?", DesertMenu, Channel);
llSetTimerEvent(30);
}
else
{
string item = "";
index = llListFindList(FoodMenu, [ message]);
if(index >= 0)item = llList2String(FoodItems, index);
else
{
index = llListFindList(DrinkMenu, [ message]);
if(index >= 0)item = llList2String(DrinkItems, index);
else
{
index = llListFindList(DesertMenu, [ message]);
if(index >= 0)item = llList2String(DesertItems, index);
else
{
llWhisper(0, "Unknown Item \"" + message + "\"");
}
}
}
// Anything to give/rez?
if(item != "")
{
// llGiveInventory(id, item);
// Assuming the Table is the item you touched for the menu.
vector pos = llGetPos();
rotation rot = llGetRot();

pos += < 0,0,0.1>;
llRezObject(item, pos * rot, <0,0,0>, rot, 0);
}

}
}

timer()
{
CancelListen();
llWhisper(0, "Menu timeout.");
}
}
_____________________
I'm back......
Belladonna DuCasse
Registered User
Join date: 26 Jan 2007
Posts: 29
05-21-2007 07:41
Thanks Newgate - I like bored people LOL!
I'll go in world and have a look now .... :))



had a look
scratched my head
the menu is beautiful, exactly what I wanted :) BUT I cant figure out why it wont rez the object I select :(
I am defeated, butterflies were easier than this ...on to the next project I think :(