Difference between revisions of "User:Fred Gandt/Scripts/Continued 3"

From Second Life Wiki
Jump to navigation Jump to search
m (cleaning up headings)
 
(41 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{LSL Header}}
{{User:Fred Gandt/Template|content=
 
[[Image:FG_jpg.jpg|thumb|right]]
 
{{RightToc|right;}}
 
== My Contributions ==
 
'''I have implemented a V# system to make it more obvious if a script is updated. The V# forms part of the title of each script.'''
 
'''If you have any comments about the content of this page please post them [[User_talk:Fred_Gandt/Scripts/Continued_3 | HERE]]'''
 
=== More Pages ===
 
'''[[User:Fred_Gandt/Scripts| Free Scripts]]''' (content constantly updating)
 
'''[[User:Fred_Gandt/Scripts/Continued_1| More Free Scripts]]''' (content constantly updating)
 
'''[[User:Fred_Gandt/Scripts/Continued_2| Even More Free Scripts]]''' (content constantly updating)
 
'''Even More More Free Scripts''' (this page)
 
'''[[User:Fred_Gandt/Scripts/Continued_4| Even More More More Free Scripts]]''' (content constantly updating)
 
=== Legal Stuff ===
 
'''[[Project:Contribution Agreement| The legal stuff about contributing to this wiki (worth reading).]]'''
 
== Tuition ==
 
'''[[User:Fred_Gandt/Tuition| Tuition scripts, notes, videos and screenshots etc.]]''' (hardly any content yet)


== Free Scripts ==
== Free Scripts ==
 
=== Script'n'Chat ===
=== Script'n'Chat ( V1 ) ===
This script is useful for presentations like teaching etc. It will post text from notecards in HUD contents at any of the 3 volumes we have ("Whisper", "Say" and "Shout"). It can read from a script (the literary kind of script (it reads notecards)) or convert ad-lib text by using an open NC as a chat window. Explanations to follow.
 
'''This script is useful for presentations like teaching etc. It will post text from notecards in HUD contents at any of the 3 volumes we have ("Whisper", "Say" and "Shout"). It can read from a script (the literary kind of script (it reads notecards)) or convert ad-lib text by using an open NC as a chat window. Explanations to follow.'''


==== HUD Maker ====
==== HUD Maker ====
First you need the object (as a HUD). Create a two prim link_set and drop the following script on it. That's the basic object. Then add to it two NC's, one called "Chat" and another called "Script". Then add the script from further down this page.


'''First you need the object (as a HUD). Create a two prim link_set and drop the following script on it. That's the basic object. Then add to it two NC's, one called "Chat" and another called "Script". Then add the script from further down this page.'''
<syntaxhighlight lang="lsl2">// V1 //
 
<lsl>// V1 //


default
default
Line 93: Line 60:
         llRemoveInventory(llGetScriptName());
         llRemoveInventory(llGetScriptName());
     }
     }
}</lsl>
}</syntaxhighlight>


==== The "Script" NC ====
==== The "Script" NC ====
The NC's can contain empty lines but, they will be ignored. The NC example below has 12 lines and that's what the HUD will tell you but, it will only let you chat 11 of them since 1 line is empty. Each line is any text added without pressing the return key. There are limits to how much text can be chatted in one go. This is a very basic script and those limits need to be worked within. Each line is chatted separately. There is no limit to how long your "Script" can be (up to the maximum a notecard can hold).


'''The NC's can contain empty lines but, they will be ignored. The NC example below has 12 lines and that's what the HUD will tell you but, it will only let you chat 11 of them since 1 line is empty. Each line is any text added without pressing the return key. There are limits to how much text can be chatted in one go. This is a very basic script and those limits need to be worked within. Each line is chatted separately. There is no limit to how long your "Script" can be (up to the maximum a notecard can hold).'''
<pre>Confessions of a cigar smoker
 
<lsl>Confessions of a cigar smoker


I owe to smoking, more or less,
I owe to smoking, more or less,
Line 110: Line 76:
And so were all the greatest jokers.
And so were all the greatest jokers.
Then ye who'd bid adieu to care,
Then ye who'd bid adieu to care,
Come here and smoke it into air.</lsl>
Come here and smoke it into air.</pre>


==== The "Chat" NC ====
==== The "Chat" NC ====
Another NC called "Chat" allows that you can chat from the same object at whatever volume is set. This NC when opened from the HUD inventory and left open on screen when the edit to the object contents is closed acts like a chat window (it can be minimized). Only the first line will be read from it. Add the text to chat and click "save". The next time you want to use that option overwrite the last text. ONE LINE ONLY.


'''Another NC called "Chat" allows that you can chat from the same object at whatever volume is set. This NC when opened from the HUD inventory and left open on screen when the edit to the object contents is closed acts like a chat window (it can be minimized). Only the first line will be read from it. Add the text to chat and click "save". The next time you want to use that option overwrite the last text. ONE LINE ONLY.'''
<pre>Whatever text you want to chat...


<lsl>Whatever text you want to chat...




 
</pre>
</lsl>


==== Script'n'Chat script ====
==== Script'n'Chat script ====
 
The following is the working script for the HUD. Place it with the NC's in the root contents. It will automatically read the NC "Script" and automatically re-read it if it is changed. Don't change the names of the NC's (I didn't make this a sophisticated script and thus it is a bit sensitive to everything being done correctly).
'''The following is the working script for the HUD. Place it with the NC's in the root contents. It will automatically read the NC "Script" and automatically re-read it if it is changed. Don't change the names of the NC's (I didn't make this a sophisticated script and thus it is a bit sensitive to everything being done correctly).'''


'''There are 7 buttons -'''
'''There are 7 buttons -'''


*'''2 Arrow buttons for navigating through the "Script" lines. A preview of the selected line is displayed on the HUD.'''
*2 Arrow buttons for navigating through the "Script" lines. A preview of the selected line is displayed on the HUD.


*'''Behind the preview of the selected line to chat is a black background. This is the face to touch to chat the displayed line.'''
*Behind the preview of the selected line to chat is a black background. This is the face to touch to chat the displayed line.


*'''3 buttons marked "WHISPER", "SAY" and "SHOUT". They are the volume selections. The volume selected will be for both "Script"ed chat and "Chat"ed chat.'''
*3 buttons marked "WHISPER", "SAY" and "SHOUT". They are the volume selections. The volume selected will be for both "Script"ed chat and "Chat"ed chat.


*'''A button marked "CHATTY". This is an on/off button for whether to chat the changes you make to the "Chat" NC. If using that option make sure "CHATTY" is selected (green).'''
*A button marked "CHATTY". This is an on/off button for whether to chat the changes you make to the "Chat" NC. If using that option make sure "CHATTY" is selected (green).


'''Oh yeah and btw... When you first wear the HUD it will be facing away from you. Turn it around.'''
Oh yeah and btw... When you first wear the HUD it will be facing away from you. Turn it around.


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


key CHAT_id;
key CHAT_id;
Line 181: Line 145:
{
{
     NC_L = s;
     NC_L = s;
     llSetText(("LINE " + ((string)(line_count + 1)) + " of " + ((string)SCRIPT_L) + " -- " + llGetSubString(NC_L, 0, 59) + "..."), <1.0,1.0,1.0>, 1.0);
     llSetText(("LINE " + ((string)(line_count + 1)) + " of " + ((string)SCRIPT_L) +
              " -- " + llGetSubString(NC_L, 0, 59) + "..."), <1.0,1.0,1.0>, 1.0);
}
}


Line 307: Line 272:
         }
         }
     }
     }
}</lsl>
}</syntaxhighlight>


=== Anti Spam Greeter ( V1 ) ===
=== Anti Spam Greeter ===
As the name suggests...This is a low spam greeter for use in medium to kinda high traffic areas. To use it place a plain prim in the entrance way of the area being visited. Drop this script onto it. The prim will turn transparent and a type of [[STATUS_PHANTOM | phantom]] called [[llVolumeDetect | "VolumeDetect"]] which means avatars will pass through it. As they pass through it (even if just a foot dips into it) the script will issue various messages depending on the settings. It can also be used to give a folder of stuff (if wanted) to the visitor. Just add the stuff (LM's, NC's, Freebies etc.) to the prim contents. You can change the contents at any time without needing to do anything to the script (unless you want the messages to change too).


'''As the name suggests...This is a low spam greeter for use in medium to kinda high traffic areas. To use it place a plain prim in the entrance way of the area being visited. Drop this script onto it. The prim will turn transparent and a type of [[STATUS_PHANTOM | phantom]] called [[llVolumeDetect | "VolumeDetect"]] which means avatars will pass through it. As they pass through it (even if just a foot dips into it) the script will issue various messages depending on the settings. It can also be used to give a folder of stuff (if wanted) to the visitor. Just add the stuff (LM's, NC's, Freebies etc.) to the prim contents. You can change the contents at any time without needing to do anything to the script (unless you want the messages to change too).'''
<syntaxhighlight lang="lsl2">// V1 //
 
<lsl>// V1 //


// Edit the strings below to set up the messaging.
// Edit the strings below to set up the messaging.
Line 460: Line 424:
         RemoveListens(NULL_KEY);
         RemoveListens(NULL_KEY);
     }
     }
}</lsl>
}</syntaxhighlight>
 
=== Grid Status Updater ( V10 ) ===
 
'''Checks the Second Life Grid Status every ten minutes to see if there are any new issues. If there are it will IM you.'''
 
'''Drop this script onto any prim that is currently not expected to do something else (e.g. a wall or floor etc) and let it run. If it is in an attachment it will work fine but, only while you are logged in. The script will maintain the name of the prim (or object if in a root) but when sending an update will use a special name set by you. This is simply more aesthetically pleasing. Getting an update from "Ceiling Fan" can seem a little odd.'''
 
<lsl>// V10 //
 
string feed_url = "http://status.secondlifegrid.net/feed/";


string alert_name = "Grid Status Update"; // The name for the prim when it sends an update.
=== Floating Text LEFT/RIGHT Alignment ===
This script can turn a list of individual lines of text into a left or right aligned floating text display.


string my_proper_name; // Used to store the "normal" name of the prim.
<syntaxhighlight lang="lsl2">// V1 //


key owner;
// SetTextAlign // Begin //
   
   
string last;
// Thank you to Silicon Plunkett for the "samples" the script uses to measure the width of the strings.
// He made a great effort to work these values out and I would have been at a massive disadvantage without them.
// This may never have existed.
   
   
key iq;
string SetTextAlign(integer A, integer D, list S)
default
{
{
     state_entry()
     list samples = [" ", "![]{}|:;'.,ijlIJ", "\/<>`()rtf", "*#\"yszxcvETYLZ", "_?upahkbnRPAFKCV", "~$^+qeodgmDB", "w=QUOSGHXN", "%WM", "@"];
    {
     list result = [];
        my_proper_name = llGetObjectName();
     string separate = "";
        owner = llGetOwner();
     if(A)
        llSetTimerEvent(600.0);
        iq = llHTTPRequest(feed_url, [], "");
     }
     timer()
    {
        iq = llHTTPRequest(feed_url, [], "");
     }
    http_response(key q, integer status, list meta, string body)
     {
     {
         if(q == iq)
         list scores = [];
        list scores_max = [];
        string line = "";
        string sample = "";
        string letter = "";
        string spaces = "";
        string to_pad = "";
        float score = 0.0;
        float max_score = 0.0;
        float next = 0.0;
        integer length = 0;
        integer s_length = 0;
        integer count = 0;
        integer count_a = 0;
        integer count_b = 0;
        integer count_c = 0;
        integer ssi = 0;
        integer padem = 0;
        integer space_count = 0;
        separate = "\n";
        length = llGetListLength(S);
        do
         {
         {
             if(status == 200)
             line = llList2String(S, count);
            s_length = llStringLength(line);
            count_a = 0;
            score = 0.0;
            do
             {
             {
                 integer index;
                 letter = llGetSubString(line, count_a, count_a);
                body = llGetSubString(body, (llSubStringIndex(body, "<item>") + 6), -1);
                 count_b = 0;
                 string latest = llStringTrim(llGetSubString(body, (llSubStringIndex(body, "<description><![CDATA[") + 22),
                 do
                                (llSubStringIndex(body, "]]></description>") - 1)), STRING_TRIM);
                 if(latest != last)
                 {
                 {
                     last = latest;
                     count_c = 0;
                     while(index != -1)
                     do
                     {
                     {
                         index = llSubStringIndex(latest, "&#8217;");
                         sample = llList2String(samples, count_c);
                         if(index != -1)
                        ssi = llSubStringIndex(sample, letter);
                         latest = llInsertString(llDeleteSubString(latest, index, (index + 6)), index, "'");
                         if(ssi != -1)
                         {
                            if(count_c == 0)
                            score += 1.0;
                            else if(count_c == 1)
                            score += 1.5;
                            else if(count_c == 2)
                            score += 2.0;
                            else if(count_c == 3)
                            score += 2.5;
                            else if(count_c == 4)  // Thanx to some advice from a veritable genius ( Xzaviar Qarnac ) -
                            score += 3.0;          // - I have realised something very important about loops.
                            else if(count_c == 5)  // Since this realization I have cut out alot of potential drag.
                            score += 3.5;          // Thank you Xzaviar.
                            else if(count_c == 6)
                            score += 4.0;
                            else if(count_c == 7)
                            score += 4.5;
                            else
                            score += 5.0;
                            count_c = 9;   // This line is what I realized was needed.
                        }
                     }
                     }
                    index = 0;
                     while((++count_c) < 9);
                     while(index != -1)
                    {
                        index = llSubStringIndex(latest, "&#62;");
                        if(index != -1)
                        latest = llInsertString(llDeleteSubString(latest, index, (index + 4)), index, ">");
                    }
                    index = 0;
                    while(index != -1)
                    {
                        index = llSubStringIndex(latest, "&#38;");
                        if(index != -1)
                        latest = llInsertString(llDeleteSubString(latest, index, (index + 4)), index, "&");
                    }
                    index = llSubStringIndex(latest, "[...]");
                    if(index != -1)
                    latest = llInsertString(llDeleteSubString(latest, index, (index + 4)), index, "...");
                    string issue = llGetSubString(body, (llSubStringIndex(body, "<title>") + 7), (llSubStringIndex(body, "</title>") - 1));
                    string dnt = llGetSubString(body, (llSubStringIndex(body, "<pubDate>") + 9), (llSubStringIndex(body, "</pubDate>") - 10));
                    string date = (llGetSubString(dnt, 0, -7) + " (UTC)");
                    string time = llGetSubString(dnt, -5, -1);
                    llSetObjectName(alert_name);
                    llInstantMessage(owner, "/me \n\nISSUE --> " + issue +
                                            "\n\nTIME --> " + time + ", " + date +
                                            "\n\nLATEST --> " + latest +
                                            "\n\nVISIT --> " + llGetSubString(feed_url, 0, -6));
                    llSetObjectName(my_proper_name);
                 }
                 }
                while((++count_b) < 1);
             }
             }
             else
             while((++count_a) < s_length);
            scores += [score];
        }
        while((++count) < length);
        scores_max = llListSort(scores, 1, FALSE);
        max_score = llList2Float(scores_max, padem);
        scores_max = [];
        do
        {
            next = llList2Float(scores, padem);
            spaces = "";
            space_count = 0;
            do
             {
             {
                 llSleep(60.0);
                 spaces += " ";
                iq = llHTTPRequest(feed_url, [], "");
             }
             }
            while((((float)(++space_count)) + next) < max_score);
            to_pad = llList2String(S, padem);
            if(D)
            result += [(to_pad + spaces)];
            else
            result += [(spaces + to_pad)];
        }
        while((++padem) < length);
        scores = [];
    }
    else
    result = S;
    return llDumpList2String(result, separate);
}
// SetTetAlign // End //
default
{
    state_entry()
    {
        float alpha = 1.0;
        vector color = <0.0,1.0,1.0>; // Turquoise!
// The text to display must be fed to the function as a list of strings each being one line (as below).
        list source = ["Hello there, Avatar!", "My script can align your text to the left or right.", "Touch me for a copy of it."];
        llSetText(SetTextAlign(TRUE, TRUE, source), color, alpha);
// SetTextAlign(Align (TRUE or FALSE), Direction (TRUE = left : FALSE = right), source).
    }
    touch_start(integer nd)
    {
        integer countnd = 0;
        do
        {
            key toucher = llDetectedKey(countnd);
            llGiveInventory(toucher, llGetScriptName()); // FREE!!! Enjoy.
         }
         }
        while((++countnd) < nd);
     }
     }
}</lsl>
}</syntaxhighlight>


=== Touch Texture Setter ( V2 ) ===
=== Very Simple Dialog Menu Inventory Giver ===
*'''Name this script something like "0000000000000000000" (zeros) so that it is definitely the first inventory item listed alphabetically.'''


'''Fill out the UUID for the texture to set. Drop the script in the prim to texture. The texture then sets on each face touched. A long held touch will delete the script.'''
Limited script. Not at all advanced. Only 12 inventory items (will update at some point). If giving away scripts, set them to not running.


<lsl>// V2 //
<syntaxhighlight lang="lsl2">// V3 //
integer lis;
integer channel;
integer busy;


key texture_uuid = "f05755e7-d31c-116d-9cf2-a4840bdfc56b";
integer noi;
 
integer tc;
 
key owner;


list StrideOfList(list src, integer stride, integer start, integer end)
{
    list l = [];
    integer ll = llGetListLength(src);
    if(start < 0)start += ll;
    if(end < 0)end += ll;
    if(end < start) return llList2List(src, start, start);
    while(start <= end)
    {
        l += llList2List(src, start, start);
        start += stride;
    }
    return l;
}
default
default
{
{
    changed(integer change)
    {
        if(change & CHANGED_INVENTORY)
        llResetScript();
    }
    on_rez(integer param)
    {
        llResetScript();
    }
     state_entry()
     state_entry()
     {
     {
         owner = llGetOwner();
         noi = (llGetInventoryNumber(INVENTORY_ALL) - 1);
     }
     }
     touch_end(integer nd)
     touch_start(integer nd)
     {
     {
         while(nd)
         if((!busy) && noi)
         {
         {
             if(llDetectedKey(--nd) == owner)
             busy = TRUE;
            key agent = llDetectedKey(0);
            list stuff = [];
            string name = "";
            integer index = 0;
            while((llGetListLength(stuff) < 24) && (index < 12))
             {
             {
                 tc = 0;
                 if((name = llGetInventoryName(INVENTORY_ALL, (++index))) != llGetScriptName())
                 llSetTexture(texture_uuid, llDetectedTouchFace(nd));
                 {
                    if(name != "")
                    stuff += [(((string)index) + " - " + name), ((string)index)];
                }
             }
             }
            llListenRemove(lis);
            channel = (llRound(llFrand(-10000000)) - 100000);
            lis = llListen(channel, llDetectedName(0), agent, "");
            llDialog(agent, ("\nSelect your inventory offer -\n" +
                            llDumpList2String(StrideOfList(stuff, 2, 0, -1), "\n")), StrideOfList(stuff, 2, 1, -1), channel);
            llSetTimerEvent(30.0);
         }
         }
     }
     }
     touch(integer nd)
     listen(integer chan, string name, key id, string msg)
     {
     {
         while(nd)
         string item = "";
        if(llGetInventoryType((item = llGetInventoryName(INVENTORY_ALL, ((integer)msg)))) != -1)
         {
         {
             if(llDetectedKey(--nd) == owner)
             llSetTimerEvent(0.0);
             {
             llListenRemove(lis);
                if((++tc) == 20)
            llGiveInventory(id, item);
                llRemoveInventory(llGetScriptName());
             busy = FALSE;
             }
         }
         }
     }
     }
}</lsl>
    timer()
    {
        llSetTimerEvent(0.0);
        llListenRemove(lis);
        busy = FALSE;
    }
}</syntaxhighlight>


=== Enzeroizer (Rotation Fixer) ( V1 ) ===
=== Very Simple Doors ===
These are not advanced door scripts. Just really simple to understand and use. In some situations you may need more advanced scripts.


'''Drop this into the root of your linked object and it will self seed to all links in a set (object). After re-rezzing the object and setting the scripts running it will set the rotations to whatever they were but with the smallest 3 decimal places made {{HoverText|000|ZERO}}. e.g. <75.458392, 128,038754, 298.836580> will become <75.458000, 128,038000, 298.836000>. This will make minor rotational drifts that occur due to one of our favorite bugs less of an issue.'''
==== Auto Door Builder ====
'''I have done light testing and think it's fine. Make a copy of you object before using this script just in case it goes wrong.'''
Drag and drop this script onto (or into) a fresh prim and like magic it will resemble a door. The most important use for this type of prim shaping is for rotating doors, since the rotations typically occur around the true center of the prim. This script path cuts the prim so that the center is at one edge. This edge then becomes the hinge point.
'''I will post an updated version using [[llGetLinkPrimitiveParams]] when server 1.38 is rolled out and actually working.'''


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


SelfSeed()
default
{
{
     integer links_in_set = llGetObjectPrimCount(llGetKey());
     state_entry()
    integer count = 2;
    do
     {
     {
         key link = llGetLinkKey(count);
         key LL_Brazillian_Rosewood = "a25bebc8-4739-453d-d44e-fc522cf95488"; // The UUID for a wood texture by Linden Labs.
         llGiveInventory(link, llGetScriptName());
        llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 0, <0.125, 0.375, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>,
                              PRIM_TEXTURE, 0, LL_Brazillian_Rosewood, <2.0, 0.1, 0.0>, <0.5, 0.025, 0.0>, 0.0,  // Set texture
                              PRIM_TEXTURE, 1, LL_Brazillian_Rosewood, <2.0, 1.0, 0.0>, <0.5, 0.0, 0.0>, 0.0,    // Set texture
                              PRIM_TEXTURE, 2, LL_Brazillian_Rosewood, <0.05, 1.0, 0.0>, <0.0125, 0.0, 0.0>, 0.0, // Set texture
                              PRIM_TEXTURE, 3, LL_Brazillian_Rosewood, <2.0, 0.1, 0.0>, <0.5, -0.025, 0.0>, 0.0,  // Set texture
                              PRIM_TEXTURE, 4, LL_Brazillian_Rosewood, <0.05, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,    // Set texture
                              PRIM_TEXTURE, 5, LL_Brazillian_Rosewood, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,    // Set texture
                              PRIM_BUMP_SHINY, ALL_SIDES, 1, 13, // Apply the "siding" bump map.
                              PRIM_SIZE, <3.0, 0.2, 3.0>]); // Set the size (after path cutting only 1/4 of the prim remains).
         llRemoveInventory(llGetScriptName()); // Self deleting script.
     }
     }
    while((++count) <= links_in_set);
}</syntaxhighlight>
}
 
==== Rotating Door ====
Simple smooth swinging type door with an auto close timer and speed of rotation setting.


Enzeroize()
<syntaxhighlight lang="lsl2">// V3 //
float angle = 90.0; // Adjust the degree of rotation (prims local Z axis).
// For clockwise rotation set a negative amount
float time = 10.0; // The amount of time the door remain open before auto closing.
// Set to zero ( 0.0 ) to disable.
///////////////////////////////////////////////////////
rotation door_open; // Used to store the open rotation.
rotation door_closed; // Used to store the closed rotation.
integer open = TRUE; // Used to instruct the Door function.
Door(integer i) // The named function and its integer instruction.
{
{
     vector rot = (llRot2Euler(llGetLocalRot())*RAD_TO_DEG);
     if(i) // If i is TRUE open the door.
     string X = ((string)rot.x);
     {
     string Y = ((string)rot.y);
        llSetLocalRot(door_open); // Set the local rotation to door_open.
     string Z = ((string)rot.z);
        llSetTimerEvent(time); // Set the timer to running.
    llSetLocalRot(llEuler2Rot(<((float)(llDeleteSubString(X, -3, -1) + "000")),
    }
                              ((float)(llDeleteSubString(Y, -3, -1) + "000")),
     else // If i is FALSE close the door.
                              ((float)(llDeleteSubString(Z, -3, -1) + "000"))>*DEG_TO_RAD));
     {
}
        llSetTimerEvent(0.0); // Stop the timer.
 
        llSetLocalRot(door_closed); // Set the local rotation to door_closed.
default
    }
    open = (!i); // Set the value of open to NOT the value of the instruction so...
}               // ...next time it is called it does the opposite.
default // Create a state for the code to run in.
{
{
     state_entry()
     state_entry() // Triggered on entering the state.
    {
        door_closed = llGetLocalRot(); // Store the rotation of the closed door.
        // The closed door is the rotation the script measures of the prim when...
        // the script is first run in it.
        door_open = llEuler2Rot(((llRot2Euler(door_closed) * RAD_TO_DEG) + <0.0, 0.0, angle>) * DEG_TO_RAD);
        // Store the rotation for the open door by adding the desired angle of rotation.
    }
    touch_start(integer nd) // Triggered when the door is touched.
    {
        Door(open); // Instruct the Door function to either open or close...
    }              // ...depending on the value of "open".
    timer() // Triggered when a timer is set and the specified time has elapsed.
     {
     {
         if(llGetLinkNumber() == 1)
         Door(FALSE); // Close the door.
        {
            SelfSeed();
            Enzeroize();
            llOwnerSay("\nTake me to your inventory and re-rez me." +
                      "\nThen open an edit on me and goto your \"Tools\" menu." +
                      "\nNear the bottom of the menu click \"Set Scripts Running In Selection\"." +
                      "\nAll the scripts will self delete after Enzeroizing.");
        }
        else
        Enzeroize();
        llRemoveInventory(llGetScriptName());
     }
     }
}</lsl>
}</syntaxhighlight>


== More Scripts... ==
==== Sliding Door ====
Very simple sliding type door with an auto close timer.


'''[[User:Fred_Gandt/Scripts| Free Scripts]]''' (content constantly updating)
<syntaxhighlight lang="lsl2">// V2 //


'''[[User:Fred_Gandt/Scripts/Continued_1| More Free Scripts]]''' (content constantly updating)
vector offset = <2.0, 0.5, 0.0>; // Set how much in each direction (X,Y,Z) the prim moves...
// ...from it's closed position.


'''[[User:Fred_Gandt/Scripts/Continued_2| Even More Free Scripts]]''' (content constantly updating)
float time = 10.0; // The amount of time the door remain open before auto closing.
// Set to zero ( 0.0 ) to disable.


'''Even More More Free Scripts''' (this page)
///////////////////////////////////////////////////////


'''[[User:Fred_Gandt/Scripts/Continued_4| Even More More More Free Scripts]]''' (content constantly updating)
vector door_open; // Used to store the open position.
 
vector door_closed; // Used to store the closed position.
 
integer open = TRUE; // Used to instruct the Door function.
 
Door(integer i) // The named function and its integer instruction.
{
    if(i) // If i is TRUE open the door.
    {
        llSetPos(door_open); // Set the local position to door_open.
        llSetTimerEvent(time); // Set the timer to running.
    }
    else // If i is FALSE close the door.
    {
        llSetTimerEvent(0.0); // Stop the timer.
        llSetPos(door_closed); // Set the local position to door_closed.
    }
    open = (!i); // Set the value of open to NOT the value of the instruction so...
}                // ...next time it is called it does the opposite.


'''If you have any comments about the content of this page please post them [[User_talk:Fred_Gandt/Scripts/Continued_3 | HERE]]'''
default // Create a state for the code to run in.
{
    on_rez(integer param) // Triggered when the door (linked or not) is rezzed.
    {
        llResetScript(); // Clear the script memory and start fresh.
    }
    changed(integer change) // Triggered when the prim senses various changes.
    { // BEWARE: This is a simple script and will not discern if the door is being sat on.
      // THE SCRIPT WILL RESET IF THE DOOR IS SAT ON.
        if(change & CHANGED_LINK) // Check if the change was in how the prim is linked.
        llResetScript(); // Reset the script to reset the positions.
    }
    state_entry() // Triggered on entering the state.
    {
        door_closed = llGetLocalPos(); // Store the local position of the closed door.
        // The closed door is the position the script measures of the prim when...
        // the script is first run in it.
        door_open = (door_closed + offset);
        // Store the position for the open door by adding the desired offset.
    }
    touch_start(integer nd) // Triggered when the door is touched.
    {
        Door(open); // Instruct the Door function to either open or close...
    }              // ...depending on the value of "open".
    timer() // Triggered when a timer is set and the specified time has elapsed.
    {
        Door(FALSE); // Close the door.
    }
}</syntaxhighlight>}}

Latest revision as of 04:10, 21 March 2017

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

Script'n'Chat

This script is useful for presentations like teaching etc. It will post text from notecards in HUD contents at any of the 3 volumes we have ("Whisper", "Say" and "Shout"). It can read from a script (the literary kind of script (it reads notecards)) or convert ad-lib text by using an open NC as a chat window. Explanations to follow.

HUD Maker

First you need the object (as a HUD). Create a two prim link_set and drop the following script on it. That's the basic object. Then add to it two NC's, one called "Chat" and another called "Script". Then add the script from further down this page.

// V1 //

default
{
    state_entry()
    {
        llSetPrimitiveParams([7,<0.01,0.58,0.04>,
                              8,<0.0,0.0,1.0,0.0>,
                              9,2,0,<0.175,0.825,0.0>,0.0,<0.0,0.0,0.0>,<1.0,1.0,0.0>,<0.0,0.0,0.0>,
                              17,0,"5748decc-f629-461c-9a36-a35a221fe21f",<1.0,1.0,0.0>,<0.0,0.0,0.0>,0.0,
                              17,1,"51519f67-926a-3301-ee64-db65c0cf1b39",<1.0,0.15,0.0>,<0.74,0.0,0.0>,0.0,
                              17,2,"5748decc-f629-461c-9a36-a35a221fe21f",<1.0,1.0,0.0>,<0.0,0.0,0.0>,0.0,
                              17,3,"0a24d0af-47a5-c7a1-e18d-2b19c5ada706",<1.0,0.15,0.0>,<0.27,0.43,0.0>,0.0,
                              17,4,"5748decc-f629-461c-9a36-a35a221fe21f",<1.0,1.0,0.0>,<0.0,0.0,0.0>,0.0,
                              17,5,"0a24d0af-47a5-c7a1-e18d-2b19c5ada706",<0.5,0.15,0.0>,<0.0,-0.415,0.0>,0.0,
                              17,6,"0a24d0af-47a5-c7a1-e18d-2b19c5ada706",<0.5,0.15,0.0>,<0.0,0.0,0.0>,0.0,
                              18,0,<1.0,1.0,1.0>,1.0,
                              18,1,<1.0,0.0,0.0>,1.0,
                              18,2,<1.0,1.0,1.0>,1.0,
                              18,3,<1.0,0.0,0.0>,1.0,
                              18,4,<1.0,1.0,1.0>,1.0,
                              18,5,<1.0,0.0,0.0>,1.0,
                              18,6,<0.0,1.0,0.0>,1.0,
                              19,0,0,0,
                              19,1,0,1,
                              19,2,0,0,
                              19,3,0,1,
                              19,4,0,0,
                              19,5,0,1,
                              19,6,0,1]);
        llSetLinkPrimitiveParams(2, [7,<0.5,0.01,0.04>,
                                     6,<0.0,0.0,0.04>,
                                     8,<-0.000137,0.000137,-0.707107,0.707107>,
                                     9,0,0,<0.375,0.875,0.0>,0.9,<0.0,0.0,0.0>,<1.0,1.0,0.0>,<0.0,0.0,0.0>,
                                     17,0,"5748decc-f629-461c-9a36-a35a221fe21f",<1.0,1.0,0.0>,<0.0,0.0,0.0>,0.0,
                                     17,1,"5748decc-f629-461c-9a36-a35a221fe21f",<1.0,1.0,0.0>,<0.0,0.0,0.0>,0.0,
                                     17,2,"5748decc-f629-461c-9a36-a35a221fe21f",<1.0,1.0,0.0>,<0.0,0.0,0.0>,0.0,
                                     17,3,"5748decc-f629-461c-9a36-a35a221fe21f",<1.0,1.0,0.0>,<0.0,0.0,0.0>,0.0,
                                     17,4,"5748decc-f629-461c-9a36-a35a221fe21f",<1.0,1.0,0.0>,<0.0,0.0,0.0>,0.0,
                                     17,5,"5748decc-f629-461c-9a36-a35a221fe21f",<1.0,1.0,0.0>,<0.0,0.0,0.0>,0.0,
                                     17,6,"c8433f60-3070-a4b7-dca3-a8ee279b6cfb",<0.7,0.8,0.0>,<0.0,0.0,0.0>,-1.570796,
                                     17,7,"c8433f60-3070-a4b7-dca3-a8ee279b6cfb",<0.7,0.8,0.0>,<0.0,0.0,0.0>,1.570796,
                                     18,0,<1.0,1.0,1.0>,1.0,
                                     18,1,<1.0,1.0,1.0>,1.0,
                                     18,2,<1.0,1.0,1.0>,1.0,
                                     18,3,<1.0,1.0,1.0>,1.0,
                                     18,4,<0.0,0.0,0.0>,1.0,
                                     18,5,<1.0,1.0,1.0>,1.0,
                                     18,6,<1.0,1.0,1.0>,1.0,
                                     18,7,<1.0,1.0,1.0>,1.0]);
        llRemoveInventory(llGetScriptName());
    }
}

The "Script" NC

The NC's can contain empty lines but, they will be ignored. The NC example below has 12 lines and that's what the HUD will tell you but, it will only let you chat 11 of them since 1 line is empty. Each line is any text added without pressing the return key. There are limits to how much text can be chatted in one go. This is a very basic script and those limits need to be worked within. Each line is chatted separately. There is no limit to how long your "Script" can be (up to the maximum a notecard can hold).

Confessions of a cigar smoker

I owe to smoking, more or less,
Through life the whole of my success;
With my Cigar I'm sage and wise -
Without, I'm dull as cloudy skies.
When smoking all my ideas soar,
When not, they sink upon the floor.
The greatest men have all been smokers,
And so were all the greatest jokers.
Then ye who'd bid adieu to care,
Come here and smoke it into air.

The "Chat" NC

Another NC called "Chat" allows that you can chat from the same object at whatever volume is set. This NC when opened from the HUD inventory and left open on screen when the edit to the object contents is closed acts like a chat window (it can be minimized). Only the first line will be read from it. Add the text to chat and click "save". The next time you want to use that option overwrite the last text. ONE LINE ONLY.

Whatever text you want to chat...



Script'n'Chat script

The following is the working script for the HUD. Place it with the NC's in the root contents. It will automatically read the NC "Script" and automatically re-read it if it is changed. Don't change the names of the NC's (I didn't make this a sophisticated script and thus it is a bit sensitive to everything being done correctly).

There are 7 buttons -

  • 2 Arrow buttons for navigating through the "Script" lines. A preview of the selected line is displayed on the HUD.
  • Behind the preview of the selected line to chat is a black background. This is the face to touch to chat the displayed line.
  • 3 buttons marked "WHISPER", "SAY" and "SHOUT". They are the volume selections. The volume selected will be for both "Script"ed chat and "Chat"ed chat.
  • A button marked "CHATTY". This is an on/off button for whether to chat the changes you make to the "Chat" NC. If using that option make sure "CHATTY" is selected (green).

Oh yeah and btw... When you first wear the HUD it will be facing away from you. Turn it around.

// V1 //

key CHAT_id;

key SCRIPT_key;

integer line_count;

key SCRIPT_id;

key SCRIPT_L_id;

key NC_L_B_id;

key NC_L_F_id;

integer SCRIPT_L;

string NC_L;

integer volume;

integer chatty;

key owner;

vector green = <0.0,1.0,0.0>;

vector red = <1.0,0.0,0.0>;

Spew(string s)
{
    if(!volume)
    llWhisper(0, ("/me \n\n" + s + "\n"));
    else if(volume == 1)
    llSay(0, ("/me \n\n" + s + "\n"));
    else if(volume == 2)
    llShout(0, ("/me \n\n" + s + "\n"));
}

Display(string s)
{
    NC_L = s;
    llSetText(("LINE " + ((string)(line_count + 1)) + " of " + ((string)SCRIPT_L) +
               " -- " + llGetSubString(NC_L, 0, 59) + "..."), <1.0,1.0,1.0>, 1.0);
}

Backward()
{
    if(line_count == 0)
    line_count = SCRIPT_L;
    NC_L_B_id = llGetNotecardLine("Script", (--line_count));
}

Forward()
{
    if(line_count == (SCRIPT_L - 1))
    line_count = -1;
    NC_L_F_id = llGetNotecardLine("Script", (++line_count));
}

default
{
    on_rez(integer param)
    {
        llResetScript();
    }
    state_entry()
    {
        owner = llGetOwner();
        llSetObjectName(llKey2Name(owner));
        llSetText("", ZERO_VECTOR, 0.0);
        volume = 1;
        llSetPrimitiveParams([PRIM_COLOR, 1, red, 1.0,
                              PRIM_COLOR, 3, red, 1.0,
                              PRIM_COLOR, 6, green, 1.0,
                              PRIM_COLOR, 5, red, 1.0]);
        SCRIPT_L_id = llGetNumberOfNotecardLines("Script");
    }
    dataserver(key q, string data)
    {
        if(q == CHAT_id)
        Spew(data);
        else if(q == SCRIPT_L_id)
        {
            SCRIPT_L = ((integer)data);
            line_count = 0;
            NC_L_F_id = llGetNotecardLine("Script", 0);
        }
        else if(q == NC_L_B_id)
        {
            if(data != "")
            Display(data);
            else
            Backward();
        }
        else if(q == NC_L_F_id)
        {
            if(data != "")
            Display(data);
            else
            Forward();
        }
    }
    changed(integer change)
    {
        if(change & CHANGED_INVENTORY)
        {
            if(chatty)
            CHAT_id = llGetNotecardLine("Chat", 0);
            else
            {
                key k = llGetInventoryKey("Script");
                if(k != SCRIPT_key)
                {
                    SCRIPT_key = k;
                    llSetText("", ZERO_VECTOR, 0.0);
                    SCRIPT_L_id = llGetNumberOfNotecardLines("Script");
                }
            }
        }
    }
    touch_start(integer nd)
    {
        integer link = llDetectedLinkNumber(0);
        integer face = llDetectedTouchFace(0);
        if(link == 1)
        {
            list params;
            if(face == 1)
            {
                chatty = (!chatty);
                if(chatty)
                params = [PRIM_COLOR, 1, green, 1.0];
                else
                params = [PRIM_COLOR, 1, red, 1.0];
            }
            else if(face == 3)
            {
                volume = 0;
                params = [PRIM_COLOR, 3, green, 1.0,
                          PRIM_COLOR, 6, red, 1.0,
                          PRIM_COLOR, 5, red, 1.0];
            }
            else if(face == 6)
            {
                volume = 1;
                params = [PRIM_COLOR, 6, green, 1.0,
                          PRIM_COLOR, 3, red, 1.0,
                          PRIM_COLOR, 5, red, 1.0];
            }
            else if(face == 5)
            {
                volume = 2;
                params = [PRIM_COLOR, 5, green, 1.0,
                          PRIM_COLOR, 3, red, 1.0,
                          PRIM_COLOR, 6, red, 1.0];
            }
            llSetPrimitiveParams(params);
        }
        else
        {
            if(face == 7)
            Backward();
            else if(face == 6)
            Forward();
            else if(face == 4)
            Spew(NC_L);
        }
    }
}

Anti Spam Greeter

As the name suggests...This is a low spam greeter for use in medium to kinda high traffic areas. To use it place a plain prim in the entrance way of the area being visited. Drop this script onto it. The prim will turn transparent and a type of phantom called "VolumeDetect" which means avatars will pass through it. As they pass through it (even if just a foot dips into it) the script will issue various messages depending on the settings. It can also be used to give a folder of stuff (if wanted) to the visitor. Just add the stuff (LM's, NC's, Freebies etc.) to the prim contents. You can change the contents at any time without needing to do anything to the script (unless you want the messages to change too).

// V1 //

// Edit the strings below to set up the messaging.

string personalize = "Welcome to to my shop"; // If empty ( "" ) no personalisation will be used.
// If not empty the personalization will prepend the first name of the visitor and the whole will prepend...
// ..."IM" and/or "DM" if used. E.g. "Welcome to to my shop Fred." would be chatted to me prepending the IM.
// If used, this messages byte count will be added to those of "IM" and "DM".

string IM = "This text will be instant messaged to the visitor.";
// If empty ( "" ) no IM will be sent.
// This MUST be limited to less than 1024 bytes ( around 300 characters ).
// If used, this messages byte count will be added to those of "personalize".

string DM = "This text will appear on the dialog ( blue dropdown with buttons ).";
// If empty ( "" ) no Dialog will be sent ( unless there are gifts ).
// This MUST be limited to less than 512 bytes ( around 150 characters ).
// If used, this messages byte count will be added to those of "personalize".

string GM = "\nSince you're here I wonder if you would like a gift?"; // If there are gifts in the contents...
// ...this will append "DM" ( it can be empty ( "" )). If used this will add to the byte count of "DM".

string folder_name = "Folder of Joy!"; // This will be the name of the folder if a gift pack is given.

string notification = "has entered your shop.";
// This message with the full name of the visitor prepended will be IMed to you if it is not empty ( "" ).

//////////////////////////////////////////////////////////////////////////////////////////////
//////YOU KNOW THE DRILL...DON'T EDIT ANYTHING BELOW UNLESS YOU KNOW WHAT YOU'RE DOING.///////
//////////////////////////////////////////////////////////////////////////////////////////////

key owner;

list visitors;

list DB = ["OK"];

list lises;

list inventory;

integer gifts;

integer lis;

integer DC;

RemoveListens(key k)
{
    if(k != NULL_KEY)
    {
        integer index = llListFindList(lises, [k]);
        if(index != -1)
        {
            llListenRemove(llList2Integer(lises, (index + 1)));
            lises = llDeleteSubList(lises, index, (index + 1));
        }
    }
    else
    {
        llListenRemove(llList2Integer(lises, 1));
        lises = llDeleteSubList(lises, 0, 1);
    }
    if(!llGetListLength(lises))
    {
        llSetTimerEvent(0.0);
        DC = (llRound(llFrand(-91746382)) - 10000);
    }
}

default
{
    state_entry()
    {
        owner = llGetOwner();
        llVolumeDetect(TRUE);
        llSetAlpha(0.0, -1);
        DC = (llRound(llFrand(-91746382)) - 10000);
        integer NOI = llGetInventoryNumber(INVENTORY_ALL);
        if(NOI > 1)
        {
            gifts = TRUE;
            DB = ["Gift Pack", "No Thanks"];
            DM += ("\n" + GM);
            string me = llGetScriptName();
            integer count;
            string name;
            do
            {
                name = llGetInventoryName(INVENTORY_ALL, count);
                if(name != me)
                inventory += [name];
            }
            while((++count) < NOI);
        }
    }
    changed(integer change)
    {
        if(change & (CHANGED_INVENTORY | CHANGED_OWNER))
        llResetScript();
    }
    collision_start(integer nd)
    {
        if(llGetListLength(lises) <= 120)
        {
            integer count;
            do
            {
                key id = llDetectedKey(count);
                string name = llDetectedName(count);
                if(llListFindList(visitors, [id]) == -1)
                {
                    string PM = "";
                    if(personalize != "")
                    PM = ("\n" + personalize + " " + llGetSubString(name, 0, (llSubStringIndex(name, " ") - 1)) + ".\n");
                    if(llGetListLength(visitors) > 200)
                    visitors = llDeleteSubList(visitors, 0, 50);
                    visitors += [id];
                    if(DM != "")
                    {
                        if(gifts)
                        {
                            llSetTimerEvent(60.0);
                            lis = llListen((++DC), name, id, "");
                            lises += [id, lis];
                        }
                        llDialog(id, (PM + DM), DB, DC);
                    }
                    if(IM != "")
                    llInstantMessage(id, (PM + IM));
                    if(notification != "")
                    llInstantMessage(owner, (name + " " + notification));
                }
            }
            while((++count) < nd);
        }
    }
    listen(integer chan, string name, key id, string msg)
    {
        if(msg == "Gift Pack")
        llGiveInventoryList(id, folder_name, inventory);
        RemoveListens(id);
    }
    timer()
    {
        RemoveListens(NULL_KEY);
    }
}

Floating Text LEFT/RIGHT Alignment

This script can turn a list of individual lines of text into a left or right aligned floating text display.

// V1 //

// SetTextAlign // Begin //
 
// Thank you to Silicon Plunkett for the "samples" the script uses to measure the width of the strings.
// He made a great effort to work these values out and I would have been at a massive disadvantage without them.
// This may never have existed.
 
string SetTextAlign(integer A, integer D, list S)
{
    list samples = [" ", "![]{}|:;'.,ijlIJ", "\/<>`()rtf", "*#\"yszxcvETYLZ", "_?upahkbnRPAFKCV", "~$^+qeodgmDB", "w=QUOSGHXN", "%WM", "@"];
    list result = [];
    string separate = "";
    if(A)
    {
        list scores = [];
        list scores_max = [];
        string line = "";
        string sample = "";
        string letter = "";
        string spaces = "";
        string to_pad = "";
        float score = 0.0;
        float max_score = 0.0;
        float next = 0.0;
        integer length = 0;
        integer s_length = 0;
        integer count = 0;
        integer count_a = 0;
        integer count_b = 0;
        integer count_c = 0;
        integer ssi = 0;
        integer padem = 0;
        integer space_count = 0;
        separate = "\n";
        length = llGetListLength(S);
        do
        {
            line = llList2String(S, count);
            s_length = llStringLength(line);
            count_a = 0;
            score = 0.0;
            do
            {
                letter = llGetSubString(line, count_a, count_a);
                count_b = 0;
                do
                {
                    count_c = 0;
                    do
                    {
                        sample = llList2String(samples, count_c);
                        ssi = llSubStringIndex(sample, letter);
                        if(ssi != -1)
                        {
                            if(count_c == 0)
                            score += 1.0;
                            else if(count_c == 1)
                            score += 1.5;
                            else if(count_c == 2)
                            score += 2.0;
                            else if(count_c == 3)
                            score += 2.5;
                            else if(count_c == 4)   // Thanx to some advice from a veritable genius ( Xzaviar Qarnac ) -
                            score += 3.0;           // - I have realised something very important about loops.
                            else if(count_c == 5)   // Since this realization I have cut out alot of potential drag.
                            score += 3.5;           // Thank you Xzaviar.
                            else if(count_c == 6)
                            score += 4.0;
                            else if(count_c == 7)
                            score += 4.5;
                            else
                            score += 5.0;
                            count_c = 9;    // This line is what I realized was needed.
                        }
                    }
                    while((++count_c) < 9);
                }
                while((++count_b) < 1);
            }
            while((++count_a) < s_length);
            scores += [score];
        }
        while((++count) < length);
        scores_max = llListSort(scores, 1, FALSE);
        max_score = llList2Float(scores_max, padem);
        scores_max = [];
        do
        {
            next = llList2Float(scores, padem);
            spaces = "";
            space_count = 0;
            do
            {
                spaces += " ";
            }
            while((((float)(++space_count)) + next) < max_score);
            to_pad = llList2String(S, padem);
            if(D)
            result += [(to_pad + spaces)];
            else
            result += [(spaces + to_pad)];
        }
        while((++padem) < length);
        scores = [];
    }
    else
    result = S;
    return llDumpList2String(result, separate);
}
 
// SetTetAlign // End //
 
default
{
    state_entry()
    {
        float alpha = 1.0;
        vector color = <0.0,1.0,1.0>; // Turquoise!
 
// The text to display must be fed to the function as a list of strings each being one line (as below).
 
        list source = ["Hello there, Avatar!", "My script can align your text to the left or right.", "Touch me for a copy of it."];
 
        llSetText(SetTextAlign(TRUE, TRUE, source), color, alpha);
 
// SetTextAlign(Align (TRUE or FALSE), Direction (TRUE = left : FALSE = right), source).
 
    }
    touch_start(integer nd)
    {
        integer countnd = 0;
        do
        {
            key toucher = llDetectedKey(countnd);
            llGiveInventory(toucher, llGetScriptName()); // FREE!!! Enjoy.
        }
        while((++countnd) < nd);
    }
}

Very Simple Dialog Menu Inventory Giver

  • Name this script something like "0000000000000000000" (zeros) so that it is definitely the first inventory item listed alphabetically.

Limited script. Not at all advanced. Only 12 inventory items (will update at some point). If giving away scripts, set them to not running.

// V3 //
 
integer lis;
 
integer channel;
 
integer busy;

integer noi;

list StrideOfList(list src, integer stride, integer start, integer end)
{
    list l = [];
    integer ll = llGetListLength(src);
    if(start < 0)start += ll;
    if(end < 0)end += ll;
    if(end < start) return llList2List(src, start, start);
    while(start <= end)
    {
        l += llList2List(src, start, start);
        start += stride;
    }
    return l;
}
 
default
{
    changed(integer change)
    {
        if(change & CHANGED_INVENTORY)
        llResetScript();
    }
    on_rez(integer param)
    {
        llResetScript();
    }
    state_entry()
    {
        noi = (llGetInventoryNumber(INVENTORY_ALL) - 1);
    }
    touch_start(integer nd)
    {
        if((!busy) && noi)
        {
            busy = TRUE;
            key agent = llDetectedKey(0);
            list stuff = [];
            string name = "";
            integer index = 0;
            while((llGetListLength(stuff) < 24) && (index < 12))
            {
                if((name = llGetInventoryName(INVENTORY_ALL, (++index))) != llGetScriptName())
                {
                    if(name != "")
                    stuff += [(((string)index) + " - " + name), ((string)index)];
                }
            }
            llListenRemove(lis);
            channel = (llRound(llFrand(-10000000)) - 100000);
            lis = llListen(channel, llDetectedName(0), agent, "");
            llDialog(agent, ("\nSelect your inventory offer -\n" +
                            llDumpList2String(StrideOfList(stuff, 2, 0, -1), "\n")), StrideOfList(stuff, 2, 1, -1), channel);
            llSetTimerEvent(30.0);
        }
    }
    listen(integer chan, string name, key id, string msg)
    {
        string item = "";
        if(llGetInventoryType((item = llGetInventoryName(INVENTORY_ALL, ((integer)msg)))) != -1)
        {
            llSetTimerEvent(0.0);
            llListenRemove(lis);
            llGiveInventory(id, item);
            busy = FALSE;
        }
    }
    timer()
    {
        llSetTimerEvent(0.0);
        llListenRemove(lis);
        busy = FALSE;
    }
}

Very Simple Doors

These are not advanced door scripts. Just really simple to understand and use. In some situations you may need more advanced scripts.

Auto Door Builder

Drag and drop this script onto (or into) a fresh prim and like magic it will resemble a door. The most important use for this type of prim shaping is for rotating doors, since the rotations typically occur around the true center of the prim. This script path cuts the prim so that the center is at one edge. This edge then becomes the hinge point.

// V2 //

default
{
    state_entry()
    {
        key LL_Brazillian_Rosewood = "a25bebc8-4739-453d-d44e-fc522cf95488"; // The UUID for a wood texture by Linden Labs.
        llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 0, <0.125, 0.375, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>,
                              PRIM_TEXTURE, 0, LL_Brazillian_Rosewood, <2.0, 0.1, 0.0>, <0.5, 0.025, 0.0>, 0.0,   // Set texture
                              PRIM_TEXTURE, 1, LL_Brazillian_Rosewood, <2.0, 1.0, 0.0>, <0.5, 0.0, 0.0>, 0.0,     // Set texture
                              PRIM_TEXTURE, 2, LL_Brazillian_Rosewood, <0.05, 1.0, 0.0>, <0.0125, 0.0, 0.0>, 0.0, // Set texture
                              PRIM_TEXTURE, 3, LL_Brazillian_Rosewood, <2.0, 0.1, 0.0>, <0.5, -0.025, 0.0>, 0.0,  // Set texture
                              PRIM_TEXTURE, 4, LL_Brazillian_Rosewood, <0.05, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,    // Set texture
                              PRIM_TEXTURE, 5, LL_Brazillian_Rosewood, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,     // Set texture
                              PRIM_BUMP_SHINY, ALL_SIDES, 1, 13, // Apply the "siding" bump map.
                              PRIM_SIZE, <3.0, 0.2, 3.0>]); // Set the size (after path cutting only 1/4 of the prim remains).
        llRemoveInventory(llGetScriptName()); // Self deleting script.
    }
}

Rotating Door

Simple smooth swinging type door with an auto close timer and speed of rotation setting.

// V3 //
 
float angle = 90.0; // Adjust the degree of rotation (prims local Z axis).
// For clockwise rotation set a negative amount
 
float time = 10.0; // The amount of time the door remain open before auto closing.
// Set to zero ( 0.0 ) to disable.
 
///////////////////////////////////////////////////////
 
rotation door_open; // Used to store the open rotation.
 
rotation door_closed; // Used to store the closed rotation.
 
integer open = TRUE; // Used to instruct the Door function.
 
Door(integer i) // The named function and its integer instruction.
{
    if(i) // If i is TRUE open the door.
    {
        llSetLocalRot(door_open); // Set the local rotation to door_open.
        llSetTimerEvent(time); // Set the timer to running.
    }
    else // If i is FALSE close the door.
    {
        llSetTimerEvent(0.0); // Stop the timer.
        llSetLocalRot(door_closed); // Set the local rotation to door_closed.
    }
    open = (!i); // Set the value of open to NOT the value of the instruction so...
}                // ...next time it is called it does the opposite.
 
default // Create a state for the code to run in.
{
    state_entry() // Triggered on entering the state.
    {
        door_closed = llGetLocalRot(); // Store the rotation of the closed door.
        // The closed door is the rotation the script measures of the prim when...
        // the script is first run in it.
        door_open = llEuler2Rot(((llRot2Euler(door_closed) * RAD_TO_DEG) + <0.0, 0.0, angle>) * DEG_TO_RAD);
        // Store the rotation for the open door by adding the desired angle of rotation.
    }
    touch_start(integer nd) // Triggered when the door is touched.
    {
        Door(open); // Instruct the Door function to either open or close...
    }               // ...depending on the value of "open".
    timer() // Triggered when a timer is set and the specified time has elapsed.
    {
        Door(FALSE); // Close the door.
    }
}

Sliding Door

Very simple sliding type door with an auto close timer.

// V2 //

vector offset = <2.0, 0.5, 0.0>; // Set how much in each direction (X,Y,Z) the prim moves...
// ...from it's closed position.

float time = 10.0; // The amount of time the door remain open before auto closing.
// Set to zero ( 0.0 ) to disable.

///////////////////////////////////////////////////////

vector door_open; // Used to store the open position.

vector door_closed; // Used to store the closed position.

integer open = TRUE; // Used to instruct the Door function.

Door(integer i) // The named function and its integer instruction.
{
    if(i) // If i is TRUE open the door.
    {
        llSetPos(door_open); // Set the local position to door_open.
        llSetTimerEvent(time); // Set the timer to running.
    }
    else // If i is FALSE close the door.
    {
        llSetTimerEvent(0.0); // Stop the timer.
        llSetPos(door_closed); // Set the local position to door_closed.
    }
    open = (!i); // Set the value of open to NOT the value of the instruction so...
}                // ...next time it is called it does the opposite.

default // Create a state for the code to run in.
{
    on_rez(integer param) // Triggered when the door (linked or not) is rezzed.
    {
        llResetScript(); // Clear the script memory and start fresh.
    }
    changed(integer change) // Triggered when the prim senses various changes.
    { // BEWARE: This is a simple script and will not discern if the door is being sat on.
      // THE SCRIPT WILL RESET IF THE DOOR IS SAT ON.
        if(change & CHANGED_LINK) // Check if the change was in how the prim is linked.
        llResetScript(); // Reset the script to reset the positions.
    }
    state_entry() // Triggered on entering the state.
    {
        door_closed = llGetLocalPos(); // Store the local position of the closed door.
        // The closed door is the position the script measures of the prim when...
        // the script is first run in it.
        door_open = (door_closed + offset);
        // Store the position for the open door by adding the desired offset.
    }
    touch_start(integer nd) // Triggered when the door is touched.
    {
        Door(open); // Instruct the Door function to either open or close...
    }               // ...depending on the value of "open".
    timer() // Triggered when a timer is set and the specified time has elapsed.
    {
        Door(FALSE); // Close the door.
    }
}

More Scripts...

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