User:Fred Gandt/Scripts/Continued 2

From Second Life Wiki
Revision as of 21:43, 4 April 2017 by Fred Gandt (talk | contribs) (a couple of improvements and a major fix to the game script)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
I get in-world very rarely these days. The knock-on effect of this, is that I am not in the best position to keep these scripts updated. Please message me in-world (forwarded to email) if you discover any bugs (that can't be simply fixed), and I'll do my best to find a solution.

My Contributions

If unsure about how to use these scripts

I have implemented a version number system to make it more obvious if a script is updated. The V# is a comment at the top of each script.

If you have any comments about the content of this page please post them HERE

All my scripts are written for compilation as MONO

More Scripts

Legal Stuff

The legal stuff about contributing to this wiki. (worth reading)

PJIRA Issue Tracker

The issues I have filed on the PJIRA

Tuition

Tuition scripts, notes, videos and screenshots etc. (hardly any content yet)

Free Scripts

Online Status Display & Pager

This will display the owners profile picture and a color coded and text texture sign that changes depending on the owners online status.

Just drop the script into a fresh prim.

<syntaxhighlight lang="lsl2">// V1 //

key owner_id; // Use to store the UUID of the owner to save having to keep asking.

string owner_name; // Use to store the name of the owner to save having to keep asking.

// This a UUID of a texture I created to show either the word "ONLINE" or "OFFLINE". key ON_OFF_line = "124cfcec-6b8d-552c-42b8-6a1179884e74";

// This is added to the owner UUID to make an HTTP request for the owners profile image UUID. string profile_url = "http://world.secondlife.com/resident/";

key name_id; // This key is used to recognize the dataserver request if it is for the name of the owner.

key online_id; // This key is used to recognize the dataserver request if it is made automatically.

key touch_request_id; // This key is used to recognize the dataserver request if it is made by a user.

key update_id; // Used to verify that the HTTP request is for an update of the profile texture.

integer lis; // This is used to store the value of a listen and to remove it when not needed.

integer channel; // This is used to store the value of the listen channel.

key requester; // This is used to store the name of a user who asks to page the owner.

string date; // Used to store the date (just in case you couldn't guess).

OnlineStatus(integer ol, integer tr) // This function carries two integer type pieces of info. { // integer ol is the the boolean online data. 1 for online and zero for offline.

 // integer tr is also boolean. It carries whether the function is being called by a user or automatically.
   list ol_params = []; // This is a local list creation.
   if(ol) // If the owner is online...
   ol_params = [17, 5, ON_OFF_line, <1.4,0.25,0.0>, <0.0,0.375,0.0>, (90*DEG_TO_RAD), // ..list the object parameters for displaying ONLINE.
                18, 5, <0.0,1.0,0.0>, 1.0,
                18, 6, <1.0,1.0,1.0>, 1.0];
   else // If not...
   ol_params = [17, 5, ON_OFF_line, <1.4,0.25,0.0>, <0.0,0.625,0.0>, (90*DEG_TO_RAD), // ..list the object parameters for displaying OFFLINE.
                18, 5, <1.0,0.0,0.0>, 1.0,
                18, 6, <0.5,0.5,0.5>, 1.0];
   llSetPrimitiveParams(ol_params); // Set the object parameters to show whatever the list is.
   if(tr) // If this was a touch request...
   {
       llSetTimerEvent(30.0); // Prepare to be ignored (we need to switch the listen off if we are ignored).
       if(ol) // If the owner is online...
       {
           lis = llListen(channel, "", requester, ""); // Open a listen for the user who made the request.
           llDialog(requester, ("\nWould you like to page " + owner_name + "?"), ["YES", "NO"], channel); // Send them a dialog.
       }
       else // If not...
       llInstantMessage(requester, (owner_name + " is currently offline.")); // Send a message explaining that the owner is offline.
   }

}

default // Create an area for the events to play in. This is called a "state". {

   state_entry() // On state entry...
   {
       owner_id = llGetOwner(); // Get the owner UUID (key) and store it.
       name_id = llRequestAgentData(owner_id, DATA_NAME); // Make a request for the owners name.
       channel = -5647; // Set a channel to use for the dialog.
   }
   dataserver(key q, string data) // Triggered when a reply to a data request is recieved.
   {
       if(q == name_id) // Check the id of the request.
       {
           owner_name = data; // Store the result.
           llSetObjectName(owner_name + "'s Online Status"); // Set the name of the object to the owner name + "'s Online Status".
           llHTTPRequest((profile_url + ((string)owner_id)), [], ""); // Request the UUID of the owners profile.
       }
       else if(q == online_id) // Check the id of the request.
       OnlineStatus(((integer)data), FALSE); // Call the OnlineStatus function for an automatic return.
       else if(q == touch_request_id) // Check the id of the request.
       OnlineStatus(((integer)data), TRUE); // Call the OnlineStatus function for a touch-by-user return.
   }
   http_response(key q, integer status, list metadata, string body) // Triggered when a response for an HTTP request is recieved.
   {
       integer tex_key_start = (llSubStringIndex(body, "imageid") + 18); // Establish the point where the image UUID is written in the page.
       integer tex_key_end = (tex_key_start + 35); // Establish the point where the image UUID ends.
       key profile_image = ((key)llGetSubString(body, tex_key_start, tex_key_end)); // Store the the profile image UUID found.
       if(q != update_id) // Check the source of the request.
       {
           llSetPrimitiveParams([9, 0, 0, <0.6,0.875,0.0>, 0.02, ZERO_VECTOR, <1.0,1.0,0.0>, ZERO_VECTOR, // Shape the object...
                                 8, llEuler2Rot(<0.0,90.0,0.0>*DEG_TO_RAD),
                                 7, <0.85,0.01,0.6>,
                                 17, -1, TEXTURE_BLANK, <1.0,1.0,0.0>, ZERO_VECTOR, 0.0,
                                 18, -1, ZERO_VECTOR, 1.0]); // ...and texture it with the owners profile image and...
           llSetPrimitiveParams([17, 6, profile_image, <1.0,1.0,0.0>, ZERO_VECTOR, (90*DEG_TO_RAD),
                                 17, 5, ON_OFF_line, <1.4,0.25,0.0>, <0.0,0.375,0.0>, (90*DEG_TO_RAD), // the ON/OFFline texture.
                                 19, 5, 0, 1,
                                 18, 6, <1.0,1.0,1.0>, 1.0,
                                 18, 5, <0.0,1.0,0.0>, 1.0,
                                 20, 5, 1,
                                 20, 6, 1]);
           llSetTimerEvent(0.1); // Move to the timer quickly to run the first OnlineStatus check.
       }
       else
       llSetPrimitiveParams([17, 6, profile_image, <1.0,1.0,0.0>, ZERO_VECTOR, (90*DEG_TO_RAD)]); // Apply the updated profile texture.
   }
   timer() // Triggered if a timer event is set to a non zero amount.
   {
       llSetTimerEvent(10.0); // Reset the timer event to trigger every 10 seconds.
       llListenRemove(lis); // Always remove any listen we have open.
       online_id = llRequestAgentData(owner_id, DATA_ONLINE); // So every 10 seconds we check if the owner is online.
       string t_date = llGetDate(); // Find out what the date is.
       if(t_date != date) // Check if the date has changed. If it has...
       {
           date = t_date; // ...store the date so the next check to return true will be roughly 24 hours later.
           update_id = llHTTPRequest((profile_url + ((string)owner_id)), [], ""); // Request an update of the UUID of the owners profile.
       }
   }
   touch_start(integer nd) // Triggered on clicking the object that contains the script.
   {
       llSetTimerEvent(0.0); // Stop the timer.
       requester = llDetectedKey(0); // Store the UUID of the person who touched us.
       touch_request_id = llRequestAgentData(owner_id, DATA_ONLINE); // Request the online status of the owner before issuing any dialogs.
   } // We do this becuse if the owner went offline 9 seconds ago we wouldn't know.
   listen(integer chan, string name, key id, string msg) // Triggered when all the specified info is recieved by the script if it has a listen open.
   {
       llListenRemove(lis); // Remove the listen.
       llSetTimerEvent(10.0); // Set the timer to run automatically.
       if(msg == "YES") // If the toucher wants to page the owner (the owner must be online)...
       { // Instant message the owner with a link that when clicked will bring up the touchers profile. This saves searching for the touchers profile.
           llInstantMessage(owner_id, ("secondlife:///app/agent/" + ((string)requester) + "/about has requested to message you."));
           llInstantMessage(requester, owner_name + " has been paged."); // Inform the toucher that the owner has been paged.
       }
   }

}</syntaxhighlight>

What's my Build?

A simple but fun game for groups to play. Players take turns building their interpretation of a suggested word or phrase, then the other players make guesses in local chat until one is correct. The player who correctly guesses what is being built becomes the new builder and the game continues.

  • Up to 9 notecards containing lists of words or phrases can be added.
  • Each time a notecard is chosen, the order in which the words will be used is randomized.
    • One word or phrase per line. Single lines should not exceed 255 bytes.
    • No empty lines.
    • Add alternative spellings (i.e. "colour" and "color") or meanings (i.e. "truck", "lorry" and "van") together on the same line, separated by pipes (this is a pipe --> "|").
    • Punctuation listed in the script will be stripped from the words and phrases.
      • Unfortunately, LSL has no RegEx and as such it is impractical to except alternatives that aren't explicitly added to the cards. An LSL parser capable of regex like deduction would be horrible, so without utilising a remote server (a possible update), the alternatives need to cover everything reasonable to expect. There is an option for the owner to be told the word or phrase being built (after which they will be excluded from that round), and it's recommended if the script is reading from a card containing potentially contentious phrases with many possible alternatives.
    • Apostrophes are also stripped.
  • Menu operated from touch.

<syntaxhighlight lang="lsl2">// V2 //

key owner; key nc_line_id; key num_of_nc_lines_id; key current_builder = NULL_KEY;

integer query_id; integer num_of_ncs; integer private_listen_id; integer public_listen_id; integer line_index; integer owner_knows;

string notecard; string current_word; string word_or_phrase;

list notecards; list dialog_list; list shuffled_line_numbers; list current_alts; list punctuation = [ ".", ",", "!", "?", ";", ":", "-", "\"" ]; // Must not contain pipes -->

More Scripts...

If you have any comments about the content of this page please post them HERE