Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // need help asap got a dialog script but not sure where to add what i want b coz im making a tardis i have added the summon around infront and demat buttons but im not sure where to add the comands to when click that option do this for that button
- integer gActionsPerPage = 9;
- list gListActions = ["Summon","Around", "Demat"];
- integer gTotalActions;
- integer gPage;
- integer gMaxPage;
- integer gChan;
- key gUser;
- BuildDialogPage(key user)
- {
- // Build a dialog menu for current page for given user
- integer start = gActionsPerPage * gPage; // starting offset
- list buttons = [ "<<", " ", ">>" ];
- if (gActionsPerPage == 10) buttons = [ "<<", ">>" ];
- else if (gActionsPerPage > 10) buttons = []; // No room for paging buttons
- // 'start + gActionsPerPage -1' might point beyond the end of the list -
- // - but LSL stops at the list end, without throwing a wobbly
- buttons += llList2List(gListActions, start, start + gActionsPerPage - 1);
- llDialog(user, "\nPage " + (string) (gPage+1) + " of " + (string) (gMaxPage + 1) + "\n\nChoose an action", buttons, gChan);
- llSetTimerEvent(60);
- default
- {
- state_entry()
- {
- gTotalActions = (gListActions != [] ); // get length of action list
- // Validate 'ActionsPerPage' value
- if (gActionsPerPage < 1 || gActionsPerPage > 12)
- {
- llOwnerSay("Invalid 'gActionsPerPage' - must be 1 to 12");
- return;
- }
- // Compute number of menu pages that will be available
- gMaxPage = (gTotalActions - 1) / gActionsPerPage;
- if (gActionsPerPage > 10)
- {
- gMaxPage = 0;
- if (gTotalActions > gActionsPerPage)
- {
- llOwnerSay("Too many actions in total for this ActionsPerPage setting");
- return;
- }
- }
- // Compute a negative communications channel based on prim UUID
- gChan = 0x80000000 | (integer) ( "0x" + (string) llGetKey() );
- state ready;
- }
- }
- state ready
- {
- touch_end(integer total_number)
- {
- gUser = llDetectedKey(0);
- state busy;
- // Changing state sets the application to a busy condition while one user is selecting from the dialogs
- // In the event of multiple 'simultaneous' touches, only one user will get a dialog
- }
- }
- state busy
- {
- state_entry()
- {
- llListen(gChan, "", gUser, ""); // This listener will be used throughout this state
- gPage = 0;
- BuildDialogPage(gUser); // Show Page 0 dialog to current user
- }
- listen (integer chan, string name, key id, string msg)
- {
- if (msg == "<<" || msg == ">>") // Page change ...
- {
- if (msg == "<<") --gPage; // Page back
- if (msg == ">>") ++gPage; // Page forward
- if (gPage < 0) gPage = gMaxPage; // cycle around pages
- if (gPage > gMaxPage) gPage = 0;
- BuildDialogPage(id);
- return;
- }
- if (msg != " ") // no action on blank menu button
- {
- // User has selected an action from the menu
- llRegionSayTo(id, 0, "You chose action <" + msg + ">");
- }
- state ready; // changing state will release ANY and ALL open listeners
- }
- timer()
- {
- llRegionSayTo(gUser, 0, "Too slow, menu cancelled");
- state ready;
- }
- state_exit()
- {
- llSetTimerEvent(0); // would be dangerous to leave a dormant timer
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement