The scripts:
NestedMenuScript
- provides nested dialog windows
- provides method of going back through menus
- provides a notecard (the notecard must be added to the object's inventory - NOT INCLUDED)
- provides a method for rotation an object on its local y-axis
- play with the value of the rotation to get the desired rotation you want
- provides a time delayed action of resetting the object so the object will return to its original rotation after being rotated
Scripts:
// ========== Nested Menu Script
// ========== Written by Doodle Fadoodle
// ===================================
// ==
// == Feel free to edit this script and use
// == for whatever purpose you need
// ==
// ===================================
// ===================================
// Create lists for menu buttons
// Make one list per dialog screen
list MAIN_MENU = ["Description", "See Cantos"];
list CANTOS = ["Canto I", "Canto II", "Canto III", "Canto IV", "Canto V", "Canto VI", "Canto VII", "Canto VIII", "more...", "...back"];
list CANTOS_MORE = ["button1", "button2"];
// Create a key to remember who is using the menus
key avatar;
// Begin script
default
{
state_entry()
{
// When object is first placed out of inventory, start listening on specific channel
// Use a negative channel to avoid confusion
// llListen syntax: llListen(channel, "object name", key, "message");
// channel is the talk channel to begin listening on (an integer value)
// "object name" is the name of an object sending a message (a string value)
// key can be the owner of the object's key, a specific avatar, or other key (a key value)
// "message" is a specific message an avatar or other object will say on a given channel (a string value)
llListen(-199392, "", NULL_KEY, "");
llSay(0, "Book cover placed - position above book."); // Not needed - just directions for object placement
}
// Actions to perform when the object is touched:
touch_start(integer total_number)
{
// Assign the key of the avatar touching the object to the key "avatar"
avatar = llDetectedKey(0);
// Create first dialog menu, the "main" menu
// llDialog syntax: llDialog(key, "text directions for the user to read explaining options available", [list_of_buttons], channel);
llDialog(avatar, "This menu allows you to gain information pertaining to this level.\nYour options include:", MAIN_MENU, -199392);
}
// Action to perform when a button is pressed. (Used through the listen function)
// This is used for ALL button options, regardless of which list the buttons are in
// All "if" or "else if" statements should be (message = "button_text") where "button_text" is what the button's are labeled as
listen(integer channel, string name, key id, string message)
{
if(message == "Description")
{
// Give a notecard through the llGiveInventory function
// llGiveInventory syntax: llGiveInventory(key, "item_in_inventory_name");
// The key is what you set from the avatar touching the object and the item (notecard in this case) must be in the object's inventory
llGiveInventory(avatar, "ParCantoI");
}
else if(message == "See Cantos")
{
// Opens another dialog menu; now we have nested menus!
llDialog(avatar, "The following Cantos refer to this level:", CANTOS, -199392);
}
else if(message == "Canto I")
{
// Ask the avatar to open a website in the user's default web browser; using llLoadURL function
// llLoadURL syntax: llLoadURL(key, "text for user to know what the website is", "website_URL");
llLoadURL(avatar, "Paradiso Canto I Online", "http://www.gutenberg.org/catalog/world/readfile?fk_files=36790&pageno=261");
}
else if(message == "Canto II")
{
llLoadURL(avatar, "Paradiso Canto II Online", "http://www.gutenberg.org/catalog/world/readfile?fk_files=36790&pageno=265");
}
else if(message == "Canto III")
{
llLoadURL(avatar, "Paradiso Canto III Online", "http://www.gutenberg.org/catalog/world/readfile?fk_files=36790&pageno=269");
}
else if(message == "Canto IV")
{
llLoadURL(avatar, "Paradiso Canto IV Online", "http://www.gutenberg.org/catalog/world/readfile?fk_files=36790&pageno=272");
}
else if(message == "Canto V")
{
llLoadURL(avatar, "Paradiso Canto V Online", "http://www.gutenberg.org/catalog/world/readfile?fk_files=36790&pageno=276");
}
else if(message == "Canto VI")
{
llLoadURL(avatar, "Paradiso Canto VI Online", "http://www.gutenberg.org/catalog/world/readfile?fk_files=36790&pageno=279");
}
else if(message == "Canto VII")
{
llLoadURL(avatar, "Paradiso Canto VII Online", "http://www.gutenberg.org/catalog/world/readfile?fk_files=36790&pageno=283");
}
else if(message == "Canto VIII")
{
llLoadURL(avatar, "Paradiso Canto VII Online", "http://www.gutenberg.org/catalog/world/readfile?fk_files=36790&pageno=287");
}
else if(message == "...back")
{
// This will open a new dialog menu which happens to be the original "main" menu!
llDialog(avatar, "This menu allows you to gain information pertaining to this level.\nYour options include:", MAIN_MENU, -199392);
}
else if(message == "more...")
{
// This is another dialog menu; still nesting our menus!
llDialog(avatar, "The following Cantos also refer to this level:", CANTOS_MORE, -199392);
}
else if(message == "button1")
{
llSay(0, "This was just an example!");
}
else if(message == "button2")
{
llSay(0, "This was a test!");
}
// This is just so a message will show up if for some reason you have not
// put an "if"/"else if" statement for a button in the list you made
else
{
llSay(0, "Um, doesn't work?");
}
}
}
// End of Script
// =========================================================================
// ========== Rotation Script
// ========== Written by Doodle Fadoodle
// ===================================
// ==
// == Feel free to edit this script and use
// == for whatever purpose you need
// ==
// ===================================
// ===================================
// Create rotation variables to store rotations
rotation original_rot;
rotation open_rot;
// Create a float variable to store the delay time for a timed event
float delay = 3.0;
// Begin script
default
{
state_entry()
{
// There is no action to perform when the object is first placed out of inventory
}
// Action to perform when the object is touched:
touch_start(integer total_number)
{
// Move to the "open" state
state open;
}
}
// Define the states
state closed
{
state_entry()
{
// When the "closed" state is entered, set the rotation of the object to the "original" rotation
// "original" rotation is defined in the "open" state
llSetRot(original_rot);
}
// Action to perform when the object is touched while in the "closed" state
touch_start(integer total_number)
{
// Move to the "open" state
state open;
}
}
state open
{
state_entry()
{
// Actions performed when the object enters the "open" state
// Set the "original" rotation variable (original_rot) to the object's current rotation
original_rot = llGetRot();
// Create and set a rotation variable to rotate the object on the object's local negative y-axis
rotation y_neg145 = llEuler2Rot(<0,-145*deg_to_rad,0>);
// Set the "new" rotation variable (open_rot) to the rotation we want
open_rot = y_neg145 * original_rot;
// Give our object the "new" rotation values
llSetRot(open_rot);
// Start our timer event after a set value of time (delay)
llSetTimerEvent(delay);
}
// Our timer event
timer()
{
// Move to the "closed" state
state closed;
}
}
// End of Script
// ====================================================================
No comments:
Post a Comment