Created
June 23, 2014 17:07
-
-
Save TechplexEngineer/a82bdb36beeb478af28d to your computer and use it in GitHub Desktop.
Ann Enigma's Notecard Selector
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Notecard Selector | |
| // by Ann Enigma | |
| // This script presents users with a list of notecards in a dialog box, and allows them to select one | |
| // Note: The names of the notecards must be less than 24 characters long | |
| // This script is licenced under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License | |
| // http://creativecommons.org/licenses/by-nc-sa/3.0/us/ | |
| // configurable options | |
| string message = "Which notecard would you like to read?"; // the message on the dialog box | |
| integer command_channel = 616; // the channel on which to listen for commands (you probably won't need to change this) | |
| // the script | |
| list notecards; | |
| default | |
| { | |
| state_entry() | |
| { | |
| integer i = 0; | |
| // read the title of each notecard into a list | |
| for(i=0;i<llGetInventoryNumber(INVENTORY_NOTECARD);i++) { | |
| notecards = (notecards=[]) + notecards + [llGetInventoryName(INVENTORY_NOTECARD,i)]; | |
| } | |
| llListen(command_channel, "", "", ""); // listen for a dialog button press | |
| } | |
| touch_start(integer total_number) | |
| { | |
| llDialog(llDetectedKey(0), message, notecards, command_channel); // present the dialog | |
| } | |
| listen(integer channel, string name, key id, string message) | |
| { | |
| if (llListFindList(notecards, (list)message) != -1) // this is a valid notecard | |
| { | |
| llGiveInventory(id, message); // give the user the notecard | |
| } | |
| } | |
| changed(integer changed_bitfield) | |
| { | |
| // if the object's inventory changes, reset the script | |
| if (changed_bitfield | CHANGED_INVENTORY) | |
| { | |
| llResetScript(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment