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

From Second Life Wiki
Jump to navigation Jump to search
(→‎Region Stats as Floating Text ( V2 ): Updated script (much better))
Line 30: Line 30:


'''[[Project:Contribution Agreement| The legal stuff about contributing to this wiki (worth reading).]]'''
'''[[Project:Contribution Agreement| The legal stuff about contributing to this wiki (worth reading).]]'''
=== PJIRA Issue Tracker ===
'''[http://jira.secondlife.com/secure/IssueNavigator.jspa?reset=true&&reporterSelect=specificuser&reporter=Fred+Gandt&sorter/field=issuekey&sorter/order=DESC The issues I have filed on the PJIRA]'''


== Tuition ==
== Tuition ==

Revision as of 19:47, 27 April 2010

FG jpg.jpg

My Contributions

If unsure about how to use these scripts

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 HERE

All my scripts are written for compilation as MONO

More Pages

Free Scripts (this page)

More Free Scripts (content constantly updating)

Even More Free Scripts (content constantly updating)

Even More More Free Scripts (content constantly updating)

Even More More More Free Scripts (content constantly updating)

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

Basic Light Switch ( V1 )

<lsl>// V1 //

// This script will cause the prim it is in to emit light. // If the prim (or object if the script is in the root of a link_set) // is touched the light will turn off if on and on if off. // The switching code can be used for many different actions.

integer on; // Global variable used to measure the condition 'on or off'.

vector color = <1.0,1.0,1.0>; // R,G,B (red, green, blue) values.

float intensity = 1.0; // 0.0 to 1.0 (1.0 = full brightness)

float radius = 20.0; // 0.1 to 20.0 (20.0 = full sphere)

float falloff = 0.01; // 0.01 to 2.0 (2.0 = least spread)

Switch() // The switching function. I made the switch function to facilitate easier editing. {

   on = (!on); // Flip the boolean value of the integer 'on'.
   llSetPrimitiveParams([PRIM_POINT_LIGHT, on, color, intensity, radius, falloff]);

}

default {

   touch_end(integer nd)
   {
       Switch(); // Unconditionally call the switch to operate.
   }

}</lsl>

Basic Alpha (transparency) SHOW/HIDE ( V1 )

<lsl>// V1 //

integer on; // Store the state of transparency.

key owner; // Store the owners UUID (key)

string command = "switch"; // Place the command to chat here. The same command will switch on and off.

integer channel = 1; // Place channel to use here (must be a positive if an avatar is chatting on it).

Switch() {

   llSetLinkAlpha(LINK_SET, ((float)on), ALL_SIDES); // This setting will turn a whole link_set transparent or solid.
   on = (!on);

}

default {

   state_entry()
   {
       owner = llGetOwner(); // Get the owner key and remember it.
       llListen(channel, "", owner, command); // This script is listening to the owner all the time.
   }   // Switching the listen off at times would be better to reduce lag. But when??
   touch_end(integer nd)
   {

// if(llDetectedKey(0) == owner) // Delete the "//" at the beginning of this line to make touches only respond to owner.

       Switch(); // Blah
   }
   listen(integer chan, string name, key id, string msg)
   {
       Switch(); // Blah
   }

}</lsl>

Basic Particle Candle Flame ON/OFF ( V1 )

This script will make the prim it is in a small glowing sphere that sits at the center of the flame.

<lsl>// V1 //

integer on; // Establish "on" as a global variable so that we can remember whether or not the flame is on.

Flame(integer num) {

   if(num) // Do we or don't we make a flame? Num is either TRUE or FALSE (1 or 0).
   {
       llParticleSystem([PSYS_PART_FLAGS, 275, // Make the flame since the condition above was met.
       PSYS_SRC_PATTERN, 4,
       PSYS_PART_START_ALPHA, 0.6,
       PSYS_PART_END_ALPHA, 0.0,
       PSYS_PART_START_COLOR, <1.0, 1.0, 0.3>,
       PSYS_PART_END_COLOR, <0.8, 0.6, 0.6>,
       PSYS_PART_START_SCALE, <0.04, 0.07, 0.0>,
       PSYS_PART_END_SCALE, <0.04, 0.04, 0.0>,
       PSYS_PART_MAX_AGE, 0.3,
       PSYS_SRC_MAX_AGE, 0.0,
       PSYS_SRC_ACCEL, <0.0, 0.0, 0.02>, // These are the parameters of the particle effect.
       PSYS_SRC_ANGLE_BEGIN, 0.0,
       PSYS_SRC_ANGLE_END, 0.0,
       PSYS_SRC_BURST_PART_COUNT, 50,
       PSYS_SRC_BURST_RATE, 0.07,
       PSYS_SRC_BURST_RADIUS, 0.0,
       PSYS_SRC_BURST_SPEED_MIN, 0.001,
       PSYS_SRC_BURST_SPEED_MAX, 0.4,
       PSYS_SRC_OMEGA, <0.0, 0.0, 0.0>,
       PSYS_SRC_TARGET_KEY,(key)"",
       PSYS_SRC_TEXTURE, ""]);
       llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <1.0, 0.8, 0.3>, 0.5, 20.0, 1.9,  // For extra effect we switch the light on too.
                             PRIM_COLOR, ALL_SIDES, <1.0,1.0,1.0>, 0.1, // And set the transparency to slightly visible.
                             PRIM_GLOW, ALL_SIDES, 0.1]); // And the glow to slight.
   }
   else // Num was not 1 (TRUE) so we need to stop the effect or not start it.
   {
       llParticleSystem([]); // Make no particles (no flame).
       llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, ZERO_VECTOR, 0.0, 0.0, 0.0,  // Switch the light off.
                             PRIM_COLOR, ALL_SIDES, <1.0,1.0,1.0>, 0.0, // And set the transparency to invisible.
                             PRIM_GLOW, ALL_SIDES, 0.0]); // And the glow to zero.
   }
   on = num; // Establish the value of the global variable "on" as being equal to the task we just performed. This acts as our memory.

}

default // Create a state for the code to run in. {

   state_entry() // On entering that state make the candle flame ignite.
   {
       llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_SPHERE, 0, <0.0,1.0,0.0>, 0.0, ZERO_VECTOR, <0.0,1.0,0.0>, // Make the prim a sphere.
                             PRIM_SIZE, <0.01,0.01,0.03>, // Make the prim the right size to act as the glowing center of the flame.
                             PRIM_TEXTURE, ALL_SIDES, TEXTURE_BLANK, ZERO_VECTOR, ZERO_VECTOR, 0.0]); // Set the blank texture.
       Flame(TRUE); // Flame(TRUE); Is an order to run the code "Flame" with the integer value "TRUE" (numerical value = 1).
   }
   touch_end(integer detected) // Detect if we have touched the candle.
   {
       Flame(!on); // We now order that the Flame() code is run with the integer value that is the oposite of what it already is.
       // (!on) = FALSE if on = TRUE and TRUE if on = FALSE. The "!" means "not".
   }

}</lsl>

Simple Alarm Clock ( V1 )

Good for reminding you about sandbox returns etc.

<lsl>// V1 //

string sound = "5e1d5f52-e7ae-0194-a412-93a96f39ff6f"; // Name of the sound in the object inventory.

                                                      // Or the UUID of any sound.

float time;

integer on;

vector active = <0.0,1.0,0.0>;

vector passive = <0.0,0.0,1.0>;

vector alarmed = <1.0,0.0,0.0>;

default {

   on_rez(integer param)
   {
       llResetScript();
   }
   state_entry()
   {
       llSetColor(passive, ALL_SIDES);
   }
   touch_end(integer nd)
   {
       if(on)
       {
           llStopSound();
           llResetScript();
       }
       else
       {
           float time_in_minutes = ((float)llGetObjectDesc()); // Write the time in minutes expressed as a float
           time = (time_in_minutes * 60);                      // in the object description before clicking to start.
           if(time < 1.0)
           {
               llOwnerSay("The time is not set.\nPlease write the time into the object description and try again");
               return;
           }
           llSetColor(active, ALL_SIDES);
           llSetTimerEvent(time);
           on = TRUE;
       }
   }
   timer()
   {
       llSetTimerEvent(0.0);
       llLoopSound(sound, 1.0);
       llSetColor(alarmed, ALL_SIDES);
   }

}</lsl>

Create HUD Mouselook Button ( V1 )

<lsl>// V1 //

key owner;

default {

   state_entry()
   {
       owner = llGetOwner();
       llRequestPermissions(owner, PERMISSION_TAKE_CONTROLS);
   }
   run_time_permissions(integer perm)
   {
       if(perm & PERMISSION_TAKE_CONTROLS) // Do we have the perms we asked for?
       llTakeControls(CONTROL_ML_LBUTTON, TRUE, FALSE); // This creates a button at the bottom of the screen
       else                    // that if pressed automatically zooms the camera of the owner into mouselook.
       llRequestPermissions(owner, PERMISSION_TAKE_CONTROLS);
   }
   control(key id, integer this, integer that)
   {                        // Adding various conditions here can change the script behavior in many ways.
       llOwnerSay("Click"); // Do stuff when clicking the left mouse button while in mouselook. Like for guns etc.
   }

}</lsl>

Float on Water (like a marker buoy) ( V1 )

<lsl>// V1 //

float offset = 0.0; // Use this float to offset the height of the object in relation to the water surface. // The object will (when the offset is zero) float with its geometric center at the level of the water surface. default // The offset is a measure of meters and/or parts thereof. {

   state_entry() // Best to set the object in place with your edit tools and then add the script.
   {             // As the code runs it will lock the objects position and attempt to remain there.
       float float_height = (llWater(ZERO_VECTOR) + offset); 
       vector pos = llGetPos();
       llSetStatus(STATUS_PHYSICS, TRUE); // Make the object physical.
       llMoveToTarget(<pos.x, pos.y, float_height>, 0.5); // Have it maintain it's position.
       // Things get more complex if you wanna make a boat. But this is a place to start.
   }

}</lsl>

Visit Web Address Dialog ( V1 )

If you have a website use something like this to direct people to it.

<lsl>// V1 //

string URL_Loader_Message = "\nCopy FREE scripts from an SL wiki page"; // Message to show on dialog.

string URL_To_Visit = "https://wiki.secondlife.com/wiki/User:Fred_Gandt"; // URL to visit.

vector Omega_Axis = <0.0,0.0,1.0>; // If you don't want spinning set this to <0.0,0.0,0.0>;

float Omega_Speed = 0.5; // Speed of spin.

float Omega_Gain = 1.0; // Strength of spin.

string Floating_Text = "FREE SCRIPTS!!\n \nTouch to visit web site.\n \n(Official SL wiki)\n \n "; // Floating text.

vector Float_Text_Color = <1.0,1.0,1.0>; // Color of floating text.

float Float_Text_Alpha = 1.0; // Transparency of floating text (1.0 is solid).

// FROM THIS POINT IT IS SCARY!! ARRGGGHHHH...!!! //

default {

   state_entry()
   {
       llTargetOmega(Omega_Axis, Omega_Speed, Omega_Gain);
       llSetText(Floating_Text, Float_Text_Color, Float_Text_Alpha);
   }
   touch_start(integer nd)
   {
       integer count = 0;
       do
       {
           key toucher = llDetectedKey(count);
           llLoadURL(toucher, URL_Loader_Message, URL_To_Visit);
       }
       while((++count) < nd);
   }

}</lsl>

AO Overriding Sit Script ( V1 )

<lsl>// V1 //

integer sit_target; // Used to store whether or not a sit target is applied.

key sitter; // Used to stor the UUID (key) of the avatar we are animating.

integer perm; // Used to store whether or not we have permissions we ask for.

string anim_name = ""; // Used to store the name of the animation we have in the objects inventory.

string sit_text = ""; // Add a word to replace the words "Sit Here" (in the pie menu) to show if right clicking to sit.

vector pose_offset = <0.0,0.0,0.01>; // This must be a non zero value. // The X,Y,Z values denote by how much in meters or parts thereof the avatars palvis is offset from the center of the prim. // There can be an offset induced by the animation its self. If this is the case trial and error is the only way forward.

vector pose_rotation = <0.0,0.0,0.0>; // This can be a zero value. // The X,Y,Z values denote the rotation in degrees that the animation is rotated around the avatars pelvis. // There can be an offset induced by the animation its self. If this is the case trial and error is the only way forward.

default {

   on_rez(integer param)
   {
       llResetScript(); // Clean the script when we rez the object.
   }
   state_entry()
   {
       if(sit_text != "") // If we have not set sit_text don't apply it.
       llSetSitText(sit_text);
       if(anim_name == "") // If we have not named an anim (Such as the internal animations)...
       {
           // ...this will get the name of an animation in the prims inventory and store it.
           anim_name = llGetInventoryName(INVENTORY_ANIMATION, 0);
           if(anim_name == "") // If there is no animation in the inventory and we havn't named one...
           {
               llSitTarget(ZERO_VECTOR, ZERO_ROTATION); // Remove any stored sit target.
               llOwnerSay("There is no animation named or in my inventory. Please add an animation so I can work properly.");
               return; // Inform the owner and do nothing else.
           }
       } // If an animation exists either in inventory or by name...
       llSitTarget(pose_offset, llEuler2Rot(pose_rotation*DEG_TO_RAD)); // Set the sit target.
       sit_target = TRUE; // Remember that we are an active seat.
   }
   changed(integer change)
   {
       if(change & CHANGED_LINK) // Sense that the object has an added link (may be an avater).
       {
           if(sit_target)
           {
               sitter = llAvatarOnSitTarget(); // If it is an avatar store the UUID (key).
               if(sitter) // Check if the sitter is still sitting.
               llRequestPermissions(sitter, PERMISSION_TRIGGER_ANIMATION); // If sitting get permission to animate.
               else
               { // The sitter must have got up or something else changed.
                   if(perm)
                   {
                       llStopAnimation(anim_name); // Make sure the sit animation we play is stopped when the avatar stands.
                       llResetScript(); // Remove the permissions we had and clean the script.
                   }
               }
           }
       }
       if(change & CHANGED_INVENTORY)
       {
           llResetScript(); // If the animation is changed reset the script to get its name.
       }
   }
   run_time_permissions(integer perms) // Use the permissions.
   {
       if(perms & PERMISSION_TRIGGER_ANIMATION) // If we have the permissions we asked for.
       {
           perm = TRUE; // Remember that we have the permissions.
           if(sitter) // If the avatar is still sitting.
           {
               llStopAnimation("sit"); // Stop the default linden sit animation.
               llSleep(0.2); // Slow it down a bit. This gives time for the avatar animation list to be sit specific.
               integer count = 0;
               list anims = llGetAnimationList(sitter); // Get a list of animations the avatar is playing.
               integer length = llGetListLength(anims); // Get the length of that list.
               do
               {
                   string anim = llList2String(anims, count); // Pick the animation from the list of animations at index count.
                   if(anim != "")
                   llStopAnimation(anim); // Stop the animation.
               }
               while((++count) < length);
               llStartAnimation(anim_name); // Animate the sitting avatar using our inventory or named animation.
           }
       }
   }

}</lsl>

Region Stats as Graphical Floating Text ( V3 )

Much more accurate results and in my opinion finer code.

<lsl>// V3 //

integer on = TRUE;

Switch() {

   if(on)
   {
       llSetTimerEvent(0.0);
       llSetText("Click Me to Enable Region Stats Display\n \n ", <1.0, 1.0, 0.0>, 1.0);
   }
   else
   {
       llSetText("Gathering Region Stats...\n \n ", <1.0, 1.0, 0.0>, 1.0);
       llSetTimerEvent(2.5);
   }
   on = (!on);

}

DisplayStats() {

   integer count;
   string d = "";
   string f = "";
   integer fps = (llRound((llGetRegionFPS() * 2.0) + 10.0) / 10);
   integer dilation = llRound((llGetRegionTimeDilation() * 10.0));
   integer combo = (dilation + fps);
   while((++count) < dilation)
   d += "||";
   count = 0;
   while((++count) < fps)
   f += "||";
   llSetText("The Region is  -  " + GetCondition((combo * 2)) +
             "\n \nNumber of Agents on Region  -  " + ((string)llGetRegionAgentCount()) +
             "\n \nRegion F.P.S.  -  " + f +
             "\nRegion Dilation  -  " + d, <1.0, ((((float)combo) / 2.0) / 10.0), 0.0>, 1.0);

}

string GetCondition(integer c) // Obviously you can change this wording if you like. { // I just thought of "health" and went with it.

   if(c == 40)
   return "TRANSCENDENT";
   else if(c > 35)
   return "ATHLETIC";
   else if(c > 30)
   return "HEALTHY";
   else if(c > 25)
   return "AVERAGE";
   else if(c > 20)
   return "ILL";
   else if(c > 15)
   return "DYING";
   else if(c > 10)
   return "CRITICAL";
   else
   return "DEAD?";

}

default {

   state_entry()
   {
       Switch();
   }
   touch_start(integer nd)
   {
       Switch();
   }
   timer()
   {
       DisplayStats();
   }

}</lsl>

Configurable Unpacker ( V1 )

<lsl>// V1 //

key owner;

string me;

integer open = FALSE;

list folder_contents;

string folder_name; // The folder name will establish from the description of the object this script is in.

// CHANGE ONLY THE SETTINGS BELOW //

integer give_this_script = TRUE; // Give this FREE script away with the other contents? Think about it....

integer allow_only_owner = FALSE; // Owner only or open to all?

integer self_delete = FALSE; // Self delete?

integer timed_deletion = FALSE; // Delete immediately after giving contents or hang around a bit?

float deletion_delay = 10.0; // Length of time to hang around in seconds (if timed_deletion is set TRUE)

string display_rez_text = ""; // Floating text on rez?

string localchat_rez_text = ""; // Chatted message on rez?

string ownerchat_rez_text = ""; // Chatted message only to owner on rez?

string display_deletion_text = ""; // Floating text before deletion?

string localchat_deletion_text = ""; // Chatted message before deletion?

string ownerchat_deletion_text = ""; // Chatted message only to owner before deletion?

vector rez_text_color = <1.0,1.0,1.0>; // Color of floating text if set to show on rez.

vector deletion_text_color = <1.0,1.0,1.0>; // Color of floating text if set to show before deletion.

float rez_text_alpha = 1.0; // Transparency of floating text if set to show on rez.

float deletion_text_alpha = 1.0; // Transparency of floating text if set to show before deletion.

// CHANGE ONLY THE SETTINGS ABOVE //

OnRezTextOptionsFunctionThingy(integer o) {

   if(display_rez_text != "")
   llSetText(display_rez_text, rez_text_color, rez_text_alpha);
   if(localchat_rez_text != "")
   llSay(0, localchat_rez_text);
   if(ownerchat_rez_text != "")
   llOwnerSay(ownerchat_rez_text);
   if(!o)
   {
       integer count = 0;
       integer NOI = llGetInventoryNumber(INVENTORY_ALL);
       if(NOI)
       {
           folder_contents = [];
           do
           {
               string name = llGetInventoryName(INVENTORY_ALL, count);
               if(name == me)
               {
                   if(give_this_script)
                   folder_contents += [name];
               }
               else
               folder_contents += [name];
           }
           while((++count) < NOI);
       }
       folder_name = llGetObjectDesc();
   }

}

default {

   on_rez(integer param)
   {
       owner = llGetOwner();
       me = llGetScriptName();
       OnRezTextOptionsFunctionThingy(FALSE);
   }
   touch_start(integer nd)
   {
       if(!open)
       {
           integer give = FALSE;
           key toucher = llDetectedKey(0);
           if(allow_only_owner)
           {
               if(toucher == owner)
               give = TRUE;
           }
           else
           {
               give = TRUE;
           }
           if(give)
           {
               open = TRUE;
               llGiveInventoryList(toucher, folder_name, folder_contents);
           }
           if(open)
           {
               if(display_deletion_text != "")
               llSetText(display_deletion_text, deletion_text_color, deletion_text_alpha);
               if(localchat_deletion_text != "")
               llSay(0, localchat_deletion_text);
               if(ownerchat_deletion_text != "")
               llOwnerSay(ownerchat_deletion_text);
               if(self_delete)
               {
                   if(timed_deletion)
                   llSetTimerEvent(deletion_delay);
                   else
                   llDie();
               }
               else
               {
                   open = FALSE;
                   OnRezTextOptionsFunctionThingy(TRUE);
               }
           }
       }
   }
   timer()
   {
       llDie();
   }

}</lsl>

Random Item Giver ( V1 )

IN ITS PRESENT STATE THIS SCRIPT SHOULD NOT BE USED TO GIVE ITEMS WITH NO COPY PERMISSIONS

<lsl>// V1 //

integer NOI;

string me;

default {

   state_entry()
   {
       me = llGetScriptName();
       NOI = (llGetInventoryNumber(INVENTORY_ALL) - 1);
   }
   touch_start(integer ND)
   {
       do
       {
           string inv;
           do
           inv = llGetInventoryName(INVENTORY_ALL, llRound(llFrand(NOI)));
           while(inv == me);
           llGiveInventory(llDetectedKey((--ND)), inv);
       }
       while(ND);
   }
   changed(integer change)
   {
       if(change & (CHANGED_INVENTORY | CHANGED_OWNER))
       llResetScript();
   }

}</lsl>

Very Basic Song Player ( V1 )

Due the the 10 second limit on sounds we need to play whole songs as a sequence of clips. This does that. There are better ways.

<lsl>// V1 //

list sounds = ["c6622a52-103d-02e3-0e12-5c241c091fdb", 9.9,

              "f490836e-cb21-9317-da33-94fbbb29c9e9", 9.9,
              "1f37690b-d58a-5a44-991e-8d8593ede0e1", 9.9,
              "ff29f85f-1b79-ad63-dd80-54359d2e73ac", 9.9,
              "f2a818da-eabc-bfb8-7b06-bc2ec1497701", 9.9,
              "c777684b-807a-f932-01be-7ef69db10292", 9.9,
              "59875acb-83a0-beba-b4cd-b6ff0314afb7", 9.9,
              "fc976d08-2175-5864-41e0-bebb82c1bdba", 9.9,
              "6c40fcf4-d2d3-255e-a5db-10b36de0c8bc", 9.9,
              "25ff4fff-c102-1151-b5e3-622769e1ce69", 9.9,
              "f5f54ccb-78d2-52b8-eff1-a8f87164f145", 9.9,
              "d06d5b37-09e0-be3c-9b74-5831ddf11b73", 9.9,
              "cfc8500c-674e-51e1-4aa4-be7fd9f8c583", 9.9,
              "cfe8abed-3dfd-3b4e-4ed2-1d7a74a8fad8", 9.9,
              "7457d238-13d3-5993-27b7-16e9997f4b6e", 9.9,
              "2999852d-3fb5-e74b-1de1-19a78b827056", 9.9,
              "7be6d9cb-446a-2547-8f04-9a123d1c9790", 9.9,
              "87b0e3c5-3fa0-1d76-f113-57c862f54501", 9.9,
              "ebfe226d-6e67-7244-4d11-51a13549b21a", 9.9,
              "e242e2ab-5fc0-1f50-5fce-2fab4bd82554", 9.9,
              "95aeff53-6679-f70d-740d-4826fd64e6ae", 9.9,
              "6bb0c581-fc91-a80b-a7dd-e94cf2189f57", 9.9,
              "6f74bd84-56d3-cb27-7764-0b57f9ffd374", 9.9,
              "fd29c2d2-ddb4-f11b-75bd-f0b8f06818db", 9.9,
              "4bf3dc5e-9fe2-8c07-2e31-7754c1294d1c", 9.9,
              "fa203259-c4e1-b79d-b3a5-fdd73cb23494", 9.9,
              "81af1b20-a139-1610-a20a-9e5376caeb18", 9.9];
              

// List of names or UUIDs and the length of time for each sound to play. // If names the sounds must be in the prim inventory.

default {

   touch_start(integer nd)
   {
       integer length = llGetListLength(sounds);
       integer count = -1;
       llWhisper(0, "/me Preloading...");
       do // Unfortunately there is a bug that can create some undesired results with preloading.
       llPreloadSound(llList2Key(sounds, (++count)));
       while((++count) < (length - 1));
       llWhisper(0, "/me ...Preloaded.");
       count = 0;
       do
       {
           llPlaySound(llList2Key(sounds, count), 1.0);
           llSleep(llList2Float(sounds, (++count)));
       }
       while((++count) < length);
   }

}</lsl>

Single Prim Double Doors

Bit jumpy because of the script delay caused by llSetPrimitiveParams but, wouldn't work without it.

Just drop the script into a fresh prim and it will become the doors.

Both can be made to allow only owner use by writing the word "owner" in the prim description before resetting the script.

Sliding Doors ( V1 )

<lsl>// V1 //

integer open;

key owner;

string owner_lock = "";

OperateDoors() {

   if(!open)
   {
       float f = 0.0;
       do
       {
           f += 0.2;
           llSetPrimitiveParams([9, 0, 0, <0.375,0.875,0.0>, 0.95, ZERO_VECTOR, <f,1.0,0.0>, ZERO_VECTOR]);
       }
       while(f < 1.0);
   }
   else
   {
       float f = 1.0;
       do
       {
           f -= 0.2;
           llSetPrimitiveParams([9, 0, 0, <0.375,0.875,0.0>, 0.95, ZERO_VECTOR, <f,1.0,0.0>, ZERO_VECTOR]);
       }
       while(f > 0.0);
   }
   llSetTimerEvent(6.0);
   open = (!open);

}

default {

   state_entry()
   {
       owner = llGetOwner();
       owner_lock = llToLower(llGetObjectDesc());
       vector pos = llGetPos();
       llSetPrimitiveParams([9, 0, 0, <0.375,0.875,0.0>, 0.95, ZERO_VECTOR, <0.0,1.0,0.0>, ZERO_VECTOR,
                             17, -1, TEXTURE_BLANK, <1.0,1.0,0.0>, ZERO_VECTOR, 0.0,
                             6, <pos.x,pos.y,(pos.z - 0.25)>,
                             18, -1, ZERO_VECTOR, 0.4,
                             8, <PI,0.0,0.0,PI>,
                             7, <3.0,5.0,0.01>]);
   }
   touch_start(integer nd)
   {
       if(owner_lock == "owner")
       {
           if(llDetectedKey(0) != owner)
           return;
       }
       OperateDoors();
   }
   timer()
   {
       llSetTimerEvent(0.0);
       if(open)
       OperateDoors();
   }

}</lsl>

Swinging Doors ( V2 )

This is more of a curiosity than of any use. I only made it for fun.

It will screw up if you move the doors or change the size and then operate it without first editing and resetting the script.

I might rework it one day. Honestly though you would get a better result with two prims.

<lsl>// V2 //

integer open;

key owner;

string owner_lock = "";

float width;

float swing;

float shift;

float shifty;

float swinger;

vector pos;

vector scale;

OperateDoors() {

   if(!open)
   {
       float f = 0.0;
       do
       {
           f += 0.05;
           swing += swinger;
           shift -= shifty;
           llSetPrimitiveParams([9, 0, 0, <0.375,0.875,0.0>, 0.95, ZERO_VECTOR, <f,1.0,0.0>, ZERO_VECTOR,
                                 7, <scale.x,scale.y,swing>,
                                 //6, <(pos.x + shift),pos.y,pos.z>]); // If Opening toward the West
                                 //6, <(pos.x - shift),pos.y,pos.z>]); // If Opening toward the East
                                 6, <pos.x,(pos.y + shift),pos.z>]); // If Opening toward the South. This is the defualt.
                                 //6, <pos.x,(pos.y - shift),pos.z>]); // If Opening toward the North.
       }
       while(f < 1.0);
   }
   else // If you want the doors to open in a different direction than the default you need to un-comment the direction you want and...
   {    // ...comment out the other directions (both above and below). Remember to rotate the prim.
       float f = 1.0;
       do
       {
           f -= 0.05;
           swing -= swinger;
           shift += shifty;
           llSetPrimitiveParams([9, 0, 0, <0.375,0.875,0.0>, 0.95, ZERO_VECTOR, <f,1.0,0.0>, ZERO_VECTOR,
                                 7, <scale.x,scale.y,swing>,
                                 //6, <(pos.x + shift),pos.y,pos.z>]); // If Opening toward the West
                                 //6, <(pos.x - shift),pos.y,pos.z>]); // If Opening toward the East
                                 6, <pos.x,(pos.y + shift),pos.z>]); // If Opening toward the South. This is the defualt.
                                 //6, <pos.x,(pos.y - shift),pos.z>]); // If Opening toward the North.
       }
       while(f > 0.0);
   }
   llSetTimerEvent(6.0);
   open = (!open);

}

default {

   state_entry()
   {
       owner = llGetOwner();
       owner_lock = llToLower(llGetObjectDesc());
       
       // The section below builds the prim and sets the correct rotation etc. Once the door is created you can comment this section out.
       // You need to comment it out if you have changed the size of the doors, moved the doors or changed the rotation of the doors.
       // Otherwise as soon as you save the changes to the direction or operate the doors it will reset its self to its default.
       
       pos = llGetPos();                                                                                // Comment out once built.
       llSetPrimitiveParams([9, 0, 0, <0.375,0.875,0.0>, 0.95, ZERO_VECTOR, <0.0,1.0,0.0>, ZERO_VECTOR, // Comment out once built.
                             17, -1, TEXTURE_BLANK, <1.0,1.0,0.0>, ZERO_VECTOR, 0.0,                    // Comment out once built.
                             6, <pos.x,pos.y,(pos.z + -2.5)>,                                           // Comment out once built.
                             18, -1, ZERO_VECTOR, 0.4,                                                  // Comment out once built.
                             8, llEuler2Rot(<90.0,0.0,180.0>*DEG_TO_RAD),                               // Comment out once built.
                             7, <6.0,6.0,0.01>]);                                                       // Comment out once built.
       
       // Only comment out the section between this commented out text.
       
       pos = llGetPos();
       scale = llGetScale();
       width = ((scale.x)/2);
       shifty = ((width/2)/20);
       swinger = (width/20);
       swing = 0.0;
   }
   touch_start(integer nd)
   {
       if(owner_lock == "owner")
       {
           if(llDetectedKey(0) != owner)
           return;
       }
       OperateDoors();
   }
   timer()
   {
       llSetTimerEvent(0.0);
       if(open)
       OperateDoors();
   }

}</lsl>

More Scripts...

Free Scripts (this page)

More Free Scripts (content constantly updating)

Even More Free Scripts (content constantly updating)

Even More More Free Scripts (content constantly updating)

Even More More More Free Scripts (content constantly updating)

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