User:Fred Gandt/Scripts

From Second Life Wiki
< User:Fred Gandt
Revision as of 12:31, 30 October 2012 by Kireji Haiku (talk | contribs) (some readability improvements)
Jump to navigation Jump to search
Fredgandt icon 1024 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

Direct Links To All Individual 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)

Even More More More More Free Scripts (content constantly updating)

Even More More More More More Free Scripts (content constantly updating)

Car Type Land Vehicle Scripts (Working on it...)

Functions For Specific Tasks

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 ( V2 )

Placed in the root of a linked object this script will make the whole object active to touch. The light will always be emitted by the prim the script is in. So, if you have a 5 prim lamp, put this in the "bulb" prim and make that prim the root. If placed in a child prim of an object, only that prim will be clickable (unless there are other touch scripts in other prims of the object).

<lsl> // version 2

// <red, green, blue> with each part limited to [0.0, 1.0] vector color = <1.0, 1.0, 1.0>;

// [0.0, 1.0] where 1.0 is full brightness float intensity = 1.0;

// [0.1, 20.0] where 20.0 is full sphere float radius = 20.0;

// [0.01, 2.0] where 2.0 is least spread float falloff = 0.01;

integer isSwitchedOn;

toggle_light() { // toggle between TRUE (1) and FALSE (0)

   isSwitchedOn = !isSwitchedOn;
   llSetLinkPrimitiveParamsFast(LINK_THIS,
       [PRIM_POINT_LIGHT, isSwitchedOn, color, intensity, radius, falloff]);

}

default {

   touch_start(integer num_detected)
   {
       toggle_light();
   }

} </lsl>

Basic Alpha (transparency) SHOW/HIDE ( V2 )

<lsl> // version 2

string commandToToggleOnAndOff = "switch";

integer chatChannel = 1;

integer isSwitchedOn;

toggle_alpha() { // toggle between TRUE (1) and FALSE (0)

   isSwitchedOn = !isSwitchedOn;

// convert integer numbers TRUE (1) and FALSE (0) to // floats to use for alpha settings 1.0 (opaque) and 0.0 (transparent)

   llSetLinkAlpha(LINK_SET, (float)isSwitchedOn, ALL_SIDES);

}

default {

   state_entry()
   {

// to listen to the owner only, uncomment the next few lines // // key ownerKey = llGetOwner(); // llListen(chatChannel, "", ownerKey, commandToToggleOnAndOff);

       llListen(chatChannel, "", NULL_KEY, commandToToggleOnAndOff);
   }
   touch_start(integer num_detected)
   {

// to resond to touches from the owner only, uncomment the next few lines // // key ownerKey = llGetOwner(); // key touchingAvatarKey = llDetectedKey(0); // // if (touchingAvatarKey != ownerKey) // return; // // else

           toggle_alpha();
   }
   listen(integer channel, string name, key id, string message)
   {
       toggle_alpha();
   }

} </lsl>

Basic Particle Candle Flame ON/OFF ( V2 )

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

<lsl> // version 2

integer isSwitchedOn;

toggle_flame(integer inputBoolean) { // store the input value in the global variable // so we can keep track of changes

   isSwitchedOn = inputBoolean;

// set default settings for disabled effect

   list listOfParticleEffectSettings = [];
   list listOfPrimLightSettings = [
       PRIM_POINT_LIGHT, FALSE, ZERO_VECTOR, 0.0, 0.0, 0.0,
       PRIM_COLOR, ALL_SIDES, <1.0, 1.0, 1.0>, 0.0,
       PRIM_GLOW, ALL_SIDES, 0.0];

// should the inputBoolean be TRUE and we stored TRUE in isSwitchedOn // we change the settings for an enabled effect

   if (isSwitchedOn)//  == TRUE
   {
       listOfParticleEffectSettings = [
           PSYS_PART_FLAGS, 275,
           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>,
           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, NULL_KEY,
           PSYS_SRC_TEXTURE, ""];
       listOfPrimLightSettings = [
           PRIM_POINT_LIGHT, TRUE, <1.0, 0.8, 0.3>, 0.5, 2.0, 1.9,
           PRIM_COLOR, ALL_SIDES, <1.0,1.0,1.0>, 0.1,
           PRIM_GLOW, ALL_SIDES, 0.1];
   }

// else // see above the default settings for disabled effect


   llParticleSystem(listOfParticleEffectSettings);
   llSetLinkPrimitiveParamsFast(LINK_THIS, listOfPrimLightSettings);

}

default {

   state_entry()
   {
       llSetLinkPrimitiveParamsFast(LINK_THIS,
           [PRIM_TYPE, PRIM_TYPE_SPHERE, 0, <0.0, 1.0, 0.0>, 0.0, ZERO_VECTOR, <0.0, 1.0, 0.0>,
           PRIM_SIZE, <0.01, 0.01, 0.03>,
           PRIM_TEXTURE, ALL_SIDES, TEXTURE_BLANK, ZERO_VECTOR, ZERO_VECTOR, 0.0]);
       toggle_flame(TRUE);
   }
   touch_start(integer num_detected)
   {
   //  enable effect if turned off, disable effect if turned on
   //  example: set to (not TRUE) if was TRUE >> FALSE
       toggle_flame(!isSwitchedOn);
   }

} </lsl>

Simple Alarm Clock ( V3 )

Good for reminding you about sandbox returns etc. Ideally worn as a single prim HUD attachment.

<lsl>// V3 //

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

                                                      // Or the UUID of any sound.

float volume = 0.5;

vector passive = <0.0,0.0,1.0>; // Color for prim when timer is off.

vector active = <0.0,1.0,0.0>; // Color for prim when timer is running.

vector alarmed = <1.0,0.0,0.0>; // Color for prim when alarm is sounding.

float time; // Used to store the timer length.

integer on; // Used to store if the timer is running.

default {

   on_rez(integer param)
   {
       llResetScript();
   }
   state_entry()
   {
       llStopSound();
       llSetColor(passive, ALL_SIDES);
       llSetObjectName("Alarm");
   }
   touch_end(integer nd)
   {
       if(on)
       llResetScript();
       else
       {
           if((time = (((float)llGetObjectDesc()) * 60)) < 1.0) // Time established from the prim description.
           {
               llOwnerSay("The time is not set.\nPlease write the time into the object description and try again");
               return;
           }
           llSetColor(active, ALL_SIDES);
           llOwnerSay("/me is set to sound in " + ((string)llRound((time / 60))) + " minutes.");
           llSetTimerEvent(time);
           on = TRUE;
           llPreloadSound(alarm);
       }
   }
   timer()
   {
       llSetTimerEvent(0.0);
       llLoopSound(alarm, volume);
       llSetColor(alarmed, ALL_SIDES);
   }

}</lsl>

Create Mouselook Button on Screen ( V2 )

When you grant permissions to this script a button will appear on screen that if pressed will send your view into mouselook. The script will (when in mouselook) react to your left mouse button clicks too.

<lsl> // version 2

key ownerKey;

default {

   changed(integer change)
   {
   //  bitwise & and not &&
       if (change & CHANGED_OWNER)
           llResetScript();
   }

// request permissions to track the owners mouse and keyboard input

   state_entry()
   {
       ownerKey = llGetOwner();
       llRequestPermissions(ownerKey, PERMISSION_TAKE_CONTROLS);
   }
   run_time_permissions(integer perm)
   {
   //  bitwise & and not &&
       if(perm & PERMISSION_TAKE_CONTROLS)

// {

           llTakeControls(CONTROL_ML_LBUTTON, TRUE, FALSE);

// }

       else

// {

           llRequestPermissions(ownerKey, PERMISSION_TAKE_CONTROLS);

// }

   }

// when button is pressed

   control(key id, integer level, integer edge)
   {

// integer start = level & edge; // integer end = ~level & edge; // integer held = level & ~edge; // integer untouched = ~(level | edge);

       llOwnerSay("Click");
   }

} </lsl>

Floating on Water (very beta) ( V2 )

This creates a movement sort of like a floating lantern. But it needs a lot of work before I will consider it even close to done.

<lsl>// V2 //

float limit = 10.0; // This is the radius that the object is allowed to drift up to. // 20.0 == a 40 meter circle.

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.

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

float float_height;

vector home;

FloatAbout(vector pos) {

   llSetTimerEvent(limit);
   @a;
   float num_x = (llFrand(limit / 2) - (limit / 4));
   float num_y = (llFrand(limit / 2) - (limit / 4));
   vector target = <(pos.x + num_x), (pos.y + num_y), float_height>;
   if(llVecDist(target, home) <= limit)
   llMoveToTarget(target, (limit * 1.5));
   else jump a;

}

default {

   on_rez(integer param)
   {
       llResetScript();
   }
   state_entry()
   {
       float_height = (llWater(ZERO_VECTOR) + offset);
       llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y, FALSE);
       llSetStatus(STATUS_PHYSICS | STATUS_PHANTOM, TRUE);
       home = llGetPos();
       llSetTimerEvent(0.1);
   }
   timer()
   {
       FloatAbout(llGetPos());
   }
   touch_end(integer nd)
   {
       if(llDetectedKey(0) == llGetOwner())
       FloatAbout((home = llGetPos()));
   }

}</lsl>

Visit Web Address Dialog ( V2 )

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

<lsl>// V2 //

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)
   {
       while(nd)
       llLoadURL(llDetectedKey(--nd), URL_Loader_Message, URL_To_Visit);
   }

}</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 ( V4 )

<lsl> // version 4

integer isSwitchedOn;

toggle_switch() { // toggle between TRUE (1) and FALSE (0)

   isSwitchedOn = !isSwitchedOn;
   if (isSwitchedOn)
   {
       llSetTimerEvent((float)FALSE);//  stop timer
       llSetText("Click Me to Enable Region Stats Display\n \n ", <1.0, 1.0, 0.0>, (float)TRUE);
       return;
   }
   llSetText("Gathering Region Stats...\n \n ", <1.0, 1.0, 0.0>, (float)TRUE);
   llSetTimerEvent(2.5);

}

display_statistics() {

   integer fps = (llRound((llGetRegionFPS() * 2.0) + 10.0) / 10);
   integer dilation = llRound((llGetRegionTimeDilation() * 10.0));
   integer combo = (dilation + fps);
   string d = "||";
   string f = "||";
   integer count;
   do
   {
       d += "||";
       f += "||";
   }
   while(++count < dilation);
   count = 0;
   do
   {
       f += "||";
   }
   while(++count < fps);
   llSetText("The Region is  -  " + get_condition((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 get_condition(integer condition) {

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

}

default {

   state_entry()
   {
       toggle_switch();
   }
   touch_start(integer num_detected)
   {
       toggle_switch();
   }
   timer()
   {
       display_statistics();
   }

} </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 ( V3 )

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

<lsl> // version 3

default {

   touch_start(integer num_detected)
   {
       key touchingAvatarKey = llDetectedKey(0);
       integer numberOfInventoryItems = llGetInventoryNumber(INVENTORY_ALL);
       if (!numberOfInventoryItems)
           return;
       string thisScript = llGetScriptName();
   @randomChosenNameWasThisScript;
       string randomInventoryItem = llGetInventoryName(INVENTORY_ALL, llRound(llFrand( (numberOfInventoryItems - 1) )));
   if (randomInventoryItem == thisScript)
       jump randomChosenNameWasThisScript;
       llGiveInventory(touchingAvatarKey, randomInventoryItem);
   }

} </lsl>

Programmable Song Player ( V2 )

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

  • You can add up to 11 (inclusive) complete songs (however many sound files there are per song) and select which to play.
  • If a song is playing you can select the next to play and a playlist is formed. The playlist can be added to at anytime during playback.
  • The volume is adjustable at anytime, including during playback.
  • Reads the song snippets from the sound files placed in the object inventory. They will be played in alphabetical/numerical order.
  • Follow the instructions at the top of the script. Very little editing is needed.
    • There is a chance that the memory will break if the playlist is made too long. V3 will include a measure against that but I have to sleep occasionally.

<lsl>// V2 //

// This list is all you need to edit. List the names of the songs (each collection of sound files that makes one song) // followed by the length of those sound clips (each song should contain clips of equal length)

// The list should be structured like so -

// list songs = ["First Song", 9.0, "Second Song", 9.65, "Third Song", 9.45];

// The names of the songs must be identical to some part of the sound files used for that song like so -

//// In the prim inventory (along with this script) -

////// Box_Of_Rain_wav_1 ////// Box_Of_Rain_wav_2 ////// Box_Of_Rain_wav_3 ////// Servant 1 ////// Servant 2 ////// Servant 3

//// In the script -

////// list songs = ["Box_Of_Rain", 9.2, "Servant", 9.8];

// The script will play the clips in alpha/numerical order so name them wisely.

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////ONLY EDIT BELOW HERE/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

list songs = ["Box_Of_Rain", 9.2, "Servant", 9.8]; // YUP! EDIT THIS BIT ;-)

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////ONLY EDIT ABOVE HERE/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

integer volume = 10;

integer lis_count;

integer playing;

integer busy;

integer part;

integer lis;

integer sl;

float delay;

list cancel = ["CANCEL"];

list playlist;

list waiting;

list song;

string vol_str = "Volume";

string song_str = "Songs";

string song_name;

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;

}

list Volumes(integer vol) {

   integer v = 0;
   list l = [];
   do
   {
       if(v != vol)
       l += [((string)v)];
   }
   while((++v) <= 10);
   return l;

}

PageOne(key k, integer c) {

   llDialog(k, "\nAdjust the volume or select a song to play?", [vol_str, song_str] + cancel, c);

}

PlaySong(string n) {

   song = [];
   integer c = -1;
   string name = "";
   do
   {
       if(llSubStringIndex((name = llGetInventoryName(INVENTORY_SOUND, (++c))), n) != -1)
       song += [name];
   }
   while(name);
   delay = llList2Float(songs, (llListFindList(songs, [n]) + 1));
   if((sl = llGetListLength(song)))
   {
       llPreloadSound(llList2String(song, (part = 0)));
       if(sl > 1)
       llPreloadSound(llList2String(song, 1));
       playing = FALSE;
       llSetTimerEvent(0.01);
   }

}

integer Chan() {

   return llRound((llFrand(-5000000.0) + -500000.0));

}

float ScaleVol(integer v) {

   return (v * 0.1);

}

Listen(integer c, key a) {

   lis = llListen(c, "", a, "");

}

RemoveListen(integer b) {

   llListenRemove(lis);
   lis_count = 0;
   if(b)
   busy = FALSE;
   lis = 0;

}

SetListenTimer(integer p) {

   if(p)
   while(((++lis_count) * llRound(delay)) < 30);
   else
   {
       lis_count = 1;
       llSetTimerEvent(30.0);
   }

}

integer CheckWaitingRoom(integer c) {

   if(waiting)
   {
       key a = llList2Key(waiting, 0);
       if(!c)
       {
           RemoveListen(0);
           Listen((c = Chan()), a);
           SetListenTimer(playing);
       }
       PageOne(a, c);
       waiting = llDeleteSubList(waiting, 0, 0);
       return 1;
   }
   return 0;

}

default {

   on_rez(integer param)
   {
       llStopSound();
       llResetScript();
   }
   changed(integer change)
   {
       if(change & CHANGED_INVENTORY)
       llResetScript();
   }
   touch_start(integer nd)
   {
       while(nd)
       {
           key agent = llDetectedKey(--nd);
           if(!busy)
           {
               busy = TRUE;
               integer channel = Chan();
               SetListenTimer(playing);
               Listen(channel, agent);
               PageOne(agent, channel);
           }
           else
           {
               list a = [agent];
               if(llListFindList(waiting, a) == -1)
               waiting += a;
           }
       }
   }
   listen(integer chan, string name, key id, string msg)
   {
       if(msg != llList2String(cancel, 0))
       {
           SetListenTimer(playing);
           if(msg == vol_str)
           {
               llDialog(id, "\nChange the volume?\nThe current volume is set at \"" + ((string)volume) + "\"", cancel + Volumes(volume), chan);
               return;
           }
           if(msg == song_str)
           {
               string current = "";
               if(playlist)
               {
                   current = "\n\nThe songs currently queued are\n\"" + llList2String(playlist, 0) + "\" (currently playing)";
                   if(llGetListLength(playlist) > 1)
                   current += "\n\"" + llDumpList2String(llList2List(playlist, 1, -1), "\"\n\"") + "\"";
               }
               llDialog(id, llGetSubString(("\nSelect a song to play?" + current), 0, 500), cancel + StrideOfList(songs, 2, 0, -1), chan);
               return;
           }
           if(llListFindList(Volumes(volume), [msg]) != -1)
           {
               llAdjustSoundVolume(ScaleVol((volume = ((integer)msg))));
               PageOne(id, chan);
               return;
           }
           if(llGetListLength((playlist += [msg])) == 1)
           PlaySong((song_name = msg));
       }
       if(CheckWaitingRoom(chan))
       return;
       RemoveListen(1);
   }
   timer()
   {
       if(playlist)
       {
           if(!playing)
           {
               llSetTimerEvent(delay);
               playing = TRUE;
           }
           llPlaySound(llList2String(song, part), ScaleVol(volume));
           if((++part) == sl)
           {
               if(llGetListLength(playlist) > 1)
               {
                   song_name = llList2String((playlist = llDeleteSubList(playlist, 0, 0)), 0);
                   llSleep(delay);
                   PlaySong(song_name);
               }
               else
               {
                   llSetTimerEvent(0.0);
                   song_name = "";
                   playing = FALSE;
                   playlist = [];
               }
           }
           else if(part == (sl - 1))
           llPreloadSound(llList2String(song, 0));
           else
           llPreloadSound(llList2String(song, (part + 1)));
       }
       if(lis && (!(--lis_count)))
       {
           if(!(CheckWaitingRoom(0)))
           RemoveListen(1);
       }
   }

}</lsl>

Single Prim Double Doors ( V3 )

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

Can be made to allow only owner use by writing the word "owner" in the prim description.

<lsl>// V3 //

float auto_close = 10.0; // The time the door remains open before auto closing. Set to zero for no auto closure.

integer open;

OperateDoors() {

   if(!open)
   {
       float f = 0.0;
       while((f += 0.01) <= 1.0)
       llSetLinkPrimitiveParamsFast(LINK_THIS, [9, 0, 0, <0.375,0.875,0.0>, 0.95, ZERO_VECTOR, <f,1.0,0.0>, ZERO_VECTOR]);
   }
   else
   {
       float f = 1.0;
       while((f -= 0.01) >= -1.0)
       llSetLinkPrimitiveParamsFast(LINK_THIS, [9, 0, 0, <0.375,0.875,0.0>, 0.95, ZERO_VECTOR, <f,1.0,0.0>, ZERO_VECTOR]);
   }
   llSetTimerEvent(auto_close);
   open = (!open);

}

default {

   state_entry()
   {
       vector pos = llGetPos();
       llSetLinkPrimitiveParamsFast(LINK_THIS, [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(llToLower(llGetObjectDesc()) == "owner")
       {
           while(nd)
           {
               if(llDetectedKey(--nd) == llGetOwner())
               OperateDoors();
           }
       }
       else
       OperateDoors();
   }
   timer()
   {
       llSetTimerEvent(0.0);
       if(open)
       OperateDoors();
   }

}</lsl>

Give Only to Agents of an Age ( V1 )

Simple freebie giver that discriminates against old people. Use to allow only newer residents to grab your freebies.

  • The measure of age isn't perfect but, the worst it will be off by is a day or so.

Load the prim up with stuff (of any type (set free scripts to "Not Running")) and the script will automatically read the contents and be ready to hand them out.

<lsl>// V1 //

integer noobage = 30; // Age in days upto which an agent is considered eligible.

string folder_name = "Folder"; // name of folder as it appears in the agents inventory.

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

list inv = [];

integer Inv = 0;

integer busy = 0;

list waiting = [];

key iq = NULL_KEY;

key Agent = NULL_KEY;

integer ThankYouForTheDays(string d) {

   return llRound((((float)llGetSubString(d, 0, 3)) * 365.25) +
                  (((float)llGetSubString(d, 5, 6)) * 30.4375) +
                  ((float)llGetSubString(d, 8, 9)));

}

integer Noob(string dob, string date) {

   if((ThankYouForTheDays(date) - ThankYouForTheDays(dob)) <= noobage)
   return 1;
   return 0;

}

default {

   on_rez(integer param)
   {
       llResetScript();
   }
   changed(integer change)
   {
       if(change & (CHANGED_OWNER | CHANGED_INVENTORY))
       llResetScript();
   }
   state_entry()
   {
       integer noi = llGetInventoryNumber(INVENTORY_ALL);
       string name;
       while(noi)
       {
           if((name = llGetInventoryName(INVENTORY_ALL, (--noi))) != llGetScriptName())
           inv += [name];
       }
       Inv = llGetListLength(inv);
   }
   touch_start(integer nd)
   {
       while(nd && Inv)
       {
           key agent = llDetectedKey(--nd);
           if(!busy)
           {
               busy = TRUE;
               iq = llRequestAgentData((Agent = agent), DATA_BORN);
           }
           else
           {
               if(llListFindList(waiting, [agent]) == -1)
               waiting += [agent];
           }
       }
   }
   dataserver(key q, string data)
   {
       if(q == iq)
       {
           if(Noob(data, llGetDate()))
           llGiveInventoryList(Agent, folder_name, inv);
           if(llGetListLength(waiting))
           {
               iq = llRequestAgentData((Agent = llList2Key(waiting, 0)), DATA_BORN);
               waiting = llDeleteSubList(waiting, 0, 0);
           }
           else
           busy = FALSE;
       }
   }

}</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)

Even More More More More Free Scripts (content constantly updating)

Even More More More More More Free Scripts (content constantly updating)

Car Type Land Vehicle Scripts (Working on it...)

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