menu driven notecard giver
|
|
Trance Broek
Registered User
Join date: 14 Jun 2007
Posts: 2
|
02-27-2008 13:59
Hello can some one help me I am trying to make a menu driven notecard giver but cant get it to give out the note cards as i can not find out how to get the key of who cick on the menu(llDialog) to the llGiveInventory command. can some one tell me what i need to do /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// integer CHANNEL = 42; // dialog channel list MENU_MAIN = ["note 1", "note 2", "note 3",]; // the main menu default { state_entry() { llListen(CHANNEL, "", NULL_KEY, ""  ; // listen for dialog answers (from multiple users) } touch_start(integer total_number) { llDialog(llDetectedKey(0), "What do you want to whant", MENU_MAIN, CHANNEL); // present dialog on click } listen(integer channel, string name, key id, string message) { if (llListFindList(MENU_MAIN, [message]) != -1) // verify dialog choice { llSay(0, name + " picked the option '" + message + "'."  ; // output the answer if (message == "note 1" llGiveInventory(llDetectedKey(0),"note 1"  ; else if (message == "note 2" llGiveInventory(llDetectedKey(0),"note 2"  ; else if (message == "note 3" llGiveInventory(llDetectedKey(0),"note 3"  ; } else llSay(0, name + " picked invalid option '" + llToLower(message) + "'."  ; // not a valid dialog choice } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
02-27-2008 14:26
integer CHANNEL = -21342; // dialog channel list MENU_MAIN =["note 1", "note 2", "note 3"]; // the main menu key detected; integer handle;
default { touch_start(integer total_number) { detected = llDetectedKey(0); handle = llListen(CHANNEL, "", detected, ""); // listen for dialog answers (from multiple users) llDialog(detected, "What do you want to want", MENU_MAIN, CHANNEL); // present dialog on click }
listen(integer channel, string name, key id, string message) { if (llListFindList(MENU_MAIN,[message]) != -1) // verify dialog choice { llSay(0, name + " picked the option '" + message + "'."); // output the answer if (message == "note 1") llGiveInventory(detected, "note 1"); else if (message == "note 2") llGiveInventory(detected, "note 2"); else if (message == "note 3") llGiveInventory(detected, "note 3"); } else llSay(0, name + " picked invalid option '" + llToLower(message) + "'."); // not a valid dialog choice llListenRemove(handle); } }
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
02-27-2008 14:37
And now I am just playing with it: integer CHANNEL = -21342; // dialog channel list MENU_MAIN =["note 1", "note 2", "note 3"]; // the main menu key detected; integer handle;
default { touch_start(integer total_number) { detected = llDetectedKey(0); handle = llListen(CHANNEL, "", detected, ""); // listen for dialog answers (from multiple users) llDialog(detected, "What do you want to want", MENU_MAIN, CHANNEL); // present dialog on click }
listen(integer channel, string name, key id, string message) { if (llListFindList(MENU_MAIN,[message]) != -1) // verify dialog choice { llSay(0, name + " picked the option '" + message + "'."); // output the answer llGiveInventory(detected, message); } llListenRemove(handle); } }
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Trance Broek
Registered User
Join date: 14 Jun 2007
Posts: 2
|
02-28-2008 10:08
Thank you very much for your help
|
|
Thaleenin Sydney
Registered User
Join date: 20 Nov 2006
Posts: 10
|
03-24-2009 17:54
what about when the menu is full? dont we need a next button to go to the next menu screen? From: Jesse Barnett And now I am just playing with it: integer CHANNEL = -21342; // dialog channel list MENU_MAIN =["note 1", "note 2", "note 3"]; // the main menu key detected; integer handle;
default { touch_start(integer total_number) { detected = llDetectedKey(0); handle = llListen(CHANNEL, "", detected, ""); // listen for dialog answers (from multiple users) llDialog(detected, "What do you want to want", MENU_MAIN, CHANNEL); // present dialog on click }
listen(integer channel, string name, key id, string message) { if (llListFindList(MENU_MAIN,[message]) != -1) // verify dialog choice { llSay(0, name + " picked the option '" + message + "'."); // output the answer llGiveInventory(detected, message); } llListenRemove(handle); } }
|
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
03-24-2009 18:01
From: Thaleenin Sydney what about when the menu is full? dont we need a next button to go to the next menu screen? http://wiki.secondlife.com/wiki/SimpleDialogMenuSystem or /54/94/235155/1.html provide various examples of how to do it.
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
03-24-2009 21:46
built ages ago, off the top of my head, as a one off for a friend, so efficiency is not optimized //--// v7-D Notecard Giver w/ MultiPage Dialog Support //--//
string cSTR_MESSAGE = "Previous Discussion Notes:\n Choose a button to recieve a copy..."; integer cINT_DIALOG_CHANNEL = -41; //-- REQ: this global (store list of buttons in order) list gLstButtons;
//-- REQ: this function list vfParseButtons( integer vIntPage ){ list vLstReturn; integer vIntLength = llGetListLength( gLstButtons ); integer vIntStart = llAbs(vIntPage) * 11;
if (vIntLength - vIntStart > 1){ if (vIntLength - vIntStart > 12){ vLstReturn += llList2List( gLstButtons, vIntStart + 9, vIntStart + 10 ); if (vIntPage < 10){ vLstReturn += ["MORE (0" + (string)(vIntPage + 1) + ")"]; } else{ vLstReturn += ["MORE (" + (string)(vIntPage + 1) + ")"]; } vLstReturn += llList2List( gLstButtons, vIntStart + 6, vIntStart + 8 ); vLstReturn += llList2List( gLstButtons, vIntStart + 3, vIntStart + 5 ); vLstReturn += llList2List( gLstButtons, vIntStart, vIntStart + 2 ); } else{ integer i = vIntLength - 1; for (i; i - 2 >= vIntStart; i -= 3){ vLstReturn += llList2List( gLstButtons, i -2, i ); } if (i >= vIntStart){ vLstReturn += llList2List( gLstButtons, vIntStart, i ); } } } return vLstReturn; }
default{ state_entry(){ llOwnerSay( "Retrieving Note List..." ); integer i = 0; integer vIntNotes = llGetInventoryNumber( INVENTORY_NOTECARD ); for (i; i < vIntNotes; ++i){ gLstButtons += [llGetInventoryName( INVENTORY_NOTECARD, i )]; } llOwnerSay( (string)vIntNotes + " Notes Available. Notecard Giver Started" ); state vsWorking; } }
state vsWorking{ state_entry(){ }
touch_start( integer vIntTouched ){ llListen( cINT_DIALOG_CHANNEL, "", llDetectedKey( 0 ), "" ); llSetTimerEvent( 30.0 ); //-- REQ: origination call llDialog( llDetectedKey( 0 ), cSTR_MESSAGE, vfParseButtons( 0 ), cINT_DIALOG_CHANNEL ); }
listen( integer vIntChannel, string vStrName, key vKeyID, string vStrMessage ){ //-- REQ: handle new page calls if (llGetSubString( vStrMessage, 0, 5 ) == "MORE ("){ llSetTimerEvent( 30.0 ); llDialog( vKeyID, cSTR_MESSAGE, vfParseButtons( (integer)llGetSubString( vStrMessage, 6, 7 ) ), cINT_DIALOG_CHANNEL ); } else{ llGiveInventory( vKeyID, vStrMessage ); } }
timer(){ llSetTimerEvent( 0.0 ); state vsListenKill; }
changed( integer vBitChanged ){ if (vBitChanged & (CHANGED_OWNER | CHANGED_INVENTORY)){ llOwnerSay( "Owner/Inventory Changed, Resetting..." ); llResetScript(); } } }
state vsListenKill{ state_entry(){ llOwnerSay( "Die, Listeners, Die!" ); state vsWorking; } }
oh yeah, no error checking on notecard name lengths... no back button either, but it'll get you started.
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|