|
Keelia DeCuir
Registered User
Join date: 18 Feb 2007
Posts: 19
|
03-28-2007 02:55
Hi, I have read Dioxide DeSantis' recent post about menus. How would I go about bringing a menu such as this up through either touching a prim (which is already in the script) or also through saying something such as "menu" on say channel 3? (Newgate Ludd's re-written script) list Menu = ["Doritos", "Sandwich", "Pringles", "Burrito"]; // menu Text list Items = ["doritos", "Sandwich", "Pringles", "Burrito"];// 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); 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."); } }
Thanks for any help you can give!
|
|
Saddeus Toll
Registered User
Join date: 16 Jan 2007
Posts: 12
|
03-28-2007 03:49
It's simple: First, add the following code: state_entry() { llListen(3,"",NULL_KEY,"menu"); }and modify the listen event function like that: listen(integer channel, string name, key id, string message) { if (channel==45) { llListenRemove(handle); llSetTimerEvent(0); integer index = llListFindList(Menu, [ message]); if(index >= 0) llGiveInventory(id, llList2String(Items, index)); } else { llDialog(id, "What Would You Like To Eat?", Menu, 45); } } }
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
03-28-2007 06:07
Its a BAD idea tgo ahve two listens in a single script. Really serious adds to the lag. First you need to ask why do you need both touch or chat activation? what do you gain over having to touch the item first? If you must have both styles of access rather than use two channels use just the main one. list Menu = ["Doritos", "Sandwich", "Pringles", "Burrito"]; // menu Text list Items = ["doritos", "Sandwich", "Pringles", "Burrito"];// Inventory object names
integer Channel = 45;
ShowDialog(key id) { llDialog(id, "What Would You Like To Eat?", Menu, Channel ); } default { state_entry() { llListen(Channel ,"",NULL_KEY,""); }
touch_start(integer num) { key id = llDetectedKey(0); ShowDialog(id); }
listen(integer channel, string name, key id, string message) { if("menu" == message) { ShowDialog(id); } else { integer index = llListFindList(Menu, [ message]); if(index >= 0) llGiveInventory(id, llList2String(Items, index)); } } }
|
|
Keelia DeCuir
Registered User
Join date: 18 Feb 2007
Posts: 19
|
03-28-2007 06:55
Thank you Saddeus and Newgate, I didn't realise it would cause lag problems, so I will avoid that like the plague then. I don't want to add to any lag problems unnecessarily!
|