User:Fred Gandt/Scripts/Continued 5

From Second Life Wiki
Jump to navigation Jump to search
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 (content constantly updating)

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 (this page)

Functions for specific tasks (hardly any content yet)

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

Prim Property Scrubber ( V2 )

Just drop it onto/into the prim you want to clean of a property and choose from the menu which properties to remove either 1 at a time or all at once.

<lsl>// V2 //

key owner;

integer passes = 0;

integer channel;

list properties = ["All", // All the properties listed below.

                  "Text",        // Floating text. Used to display text typically above a prim.
                  "Particles",   // Used in "Poofers" for example.
                  "TextureAnim", // Texture Animation. Used to make textures on faces of prims move.
                  "Sit Target",  // Used in seats and poseballs. Sets an alternative sit position than the default.
                  "Mouselook",   // Forced Mouselook. Used to force an agents view to mouselook when sitting on the prim.
                  "Sit Text",    // Text other than the default "Sit Here" shown on the right click pie menu.
                  "Touch Text",  // Text other than the default "Touch" shown on the right click pie menu.
                  "Status's",    // There are many status's that can be set in prims. See the wiki (llSetStatus) for details.
                  "Sound",       // Looping sound emitting from the prim.
                  "Light"];      // Light emitting from the prim.

RP(integer i) {

   ++passes;
   if(i == 1)
   llSetText("", <0.0,0.0,0.0>, 0.0);
   else if(i == 2)
   llParticleSystem([]);
   else if(i == 3)
   llSetTextureAnim(0, -1, 0, 0, 0.0, 0.0, 1.0);
   else if(i == 4)
   llSitTarget(<0.0,0.0,0.0>, <0.0,0.0,0.0,1.0>);
   else if(i == 5)
   llForceMouselook(0);
   else if(i == 6)
   llSetSitText("");
   else if(i == 7)
   llSetTouchText("");
   else if(i == 8)
   {
       llSetStatus(14, 1);
       llSetStatus(251, 0);
   }
   else if(i == 9)
   llStopSound();
   else if(i == 10)
   llSetPrimitiveParams([23, 0, <0.0,0.0,0.0>, 0.0, 0.0, 0.0]);

}

RemoveProperty(integer i) {

   if(!i)
   {
       while(i < 10)
       RP(++i);
       RemoveScript();
   }
   else
   RP(i);
   if(passes < 10)
   llDialog(owner, "\nRemove Properties", ["Finished"] +
   (properties = llListReplaceList(properties, ["-"], i, i)), channel);
   else
   RemoveScript();

}

RemoveScript() {

   llRemoveInventory(llGetScriptName());

}

default {

   state_entry()
   {
       owner = llGetOwner();
       llListen((channel = (llRound(llFrand(-10000000)) - 100000)), llKey2Name(owner), owner, "");
       llDialog(owner, "\nRemove Properties", ["Finished"] + properties, channel);
       llSetTimerEvent(60.0);
   }
   listen(integer chan, string name, key id, string msg)
   {
       llSetTimerEvent(60.0);
       integer index = 0;
       if((index = llListFindList(properties, [msg])) != -1)
       {
           if(msg != "-")
           RemoveProperty(index);
           else
           llDialog(owner, "\nRemove Properties", ["Finished"] + properties, channel);
       }
       else if(msg == "Finished")
       RemoveScript();
   }
   timer()
   {
       llOwnerSay("Removing script since you're not using it.");
       RemoveScript();
   }

}</lsl>

Basic Notecard Readers

Two simple methods of reading from a notecard in the prim contents with one of these scripts.

Cyclically Sequential Lines ( V1 )

<lsl>// V1 //

key iq;

integer line;

GetLine(integer i) {

   iq = llGetNotecardLine(llGetInventoryName(INVENTORY_NOTECARD, 0), i);

}

default {

   dataserver(key q, string data)
   {
       if(q == iq)
       {
           ++line;
           if(data != EOF)
           {
               if(data != "")
               llSay(0, data);
               else
               GetLine(line);
           }
           else
           GetLine((line = 0));
       }
   }
   touch_start(integer nd)
   {
       if(llGetInventoryNumber(INVENTORY_NOTECARD))
       GetLine(line);
   }

}</lsl>

Random Lines ( V1 )

<lsl>// V1 //

key iq;

key qi;

integer line;

integer lines;

GetLine(integer i) {

   iq = llGetNotecardLine(llGetInventoryName(INVENTORY_NOTECARD, 0), i);

}

default {

   changed(integer change)
   {
       if(change & CHANGED_INVENTORY)
       llResetScript();
   }
   state_entry()
   {
       if(llGetInventoryNumber(INVENTORY_NOTECARD))
       qi = llGetNumberOfNotecardLines(llGetInventoryName(INVENTORY_NOTECARD, 0));
   }
   dataserver(key q, string data)
   {
       if(q == qi)
       lines = (((integer)data) - 1);
       else if(q == iq)
       {
           if(data != "")
           llSay(0, data);
           else
           GetLine((++line));
       }
   }
   touch_start(integer nd)
   {
       if(llGetInventoryNumber(INVENTORY_NOTECARD))
       GetLine((line = llRound(llFrand(((float)lines)))));
   }

}</lsl>

CamHUD ( V1 )

Simple two function scripted camera controller. When turned on, the camera position locks in whatever place it was at the time of activation. To change the camera position, turn the HUD off...move the camera to the desired position...turn the HUD back on.

  • There are two buttons - One marked "Track" and another marked "Power".
    • "Power" (I think) has a fairly obvious function.
    • "Track" switches on and off, tracking of the owner. With tracking off the camera is locked solid. With tracking on the camera position is locked but it rotates to follow you around if you move.

The usefulness of this is up to you to decide.

Create the Object

To create the object use the following script. Just drop it onto/into a fresh prim. The resulting prim is quite small since it is designed to be a low impact HUD.

<lsl>// V1 //

default {

   state_entry()
   {
       llSetObjectName("CamHUD"); // You can change this after if you want.
       llSetPrimitiveParams([7, <0.01, 0.05, 0.025>,
                             8, <1.0, 0.0, 0.0, 0.0>,
                             9, 0, 0, <0.125, 0.625, 0.0>, 0.1, <0.0, 0.0, 0.0>, <1.0, 1.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]);
       llRemoveInventory(llGetScriptName()); // Done its job so self deletes.
   }

}</lsl>

CamHUD Script

Drop this script into the prim you just created. Wear the object as a HUD. If you do not see two distinct buttons separated by a black line, it is probably back to front or something.

<lsl>// V1 //

integer perms;

integer track;

integer on;

vector red = <1.0,0.0,0.0>;

vector green = <0.0,1.0,0.0>;

SetCameraParams(integer o, integer t) {

   list focus = [];
   llClearCameraParams();
   if(t)
   focus = [CAMERA_FOCUS, llGetPos()];
   else
   focus = [CAMERA_FOCUS_LOCKED, TRUE];
   llSetCameraParams([CAMERA_ACTIVE, o, CAMERA_POSITION_LOCKED, TRUE] + focus);

}

default {

   on_rez(integer param)
   {
       llResetScript();
   }
   state_entry()
   {
       if(llGetAttached())
       llRequestPermissions(llGetOwner(), PERMISSION_CONTROL_CAMERA);
   }
   run_time_permissions(integer perm)
   {
       if(perm & PERMISSION_CONTROL_CAMERA)
       {
           perms = TRUE;
           llSetText("   Track | Power", <1.0,1.0,1.0>, 1.0);
           llSetLinkPrimitiveParamsFast(-1, [PRIM_COLOR, -1, <0.0,0.0,0.0>, 1.0,
                                             PRIM_COLOR, 6, red, 1.0,
                                             PRIM_COLOR, 7, red, 1.0]);
       }
   }
   touch_start(integer nd)
   {
       if(perms)
       {
           integer face;
           vector color;
           if((face = llDetectedTouchFace(0)) == 6)
           {
               SetCameraParams((on = (!on)), track);
               if(on)
               color = green;
               else
               color = red;
           }
           else if(face == 7)
           {
               SetCameraParams(on, (track = (!track)));
               if(track)
               color = green;
               else
               color = red;
           }
           llSetLinkPrimitiveParamsFast(-1, [PRIM_COLOR, face, color, 1.0]);
       }
   }

}</lsl>

Simple Profit Share Vendor ( V1 )

  • THIS SCRIPT WILL ASK FOR DEBIT PERMISSIONS. THEY MUST BE GRANTED FOR THE SCRIPT TO FUNCTION. L$ WILL BE TAKEN FROM THE OBJECT OWNERS ACCOUNT.

Sell the contents of an object (if in a link_set (multiple prim object) place in the root) for another creator. They get paid their cut and you get yours. You may provide a collection of inventory including LM's and/or NC's along with the main product. The script will pay the percentage to the creator named; The inventory may be created by multiple agents. If the creator named did not create anything in the inventory the script will ask that you start again.

<lsl>// V1 //

integer price = 5; // Price of inventory. Must be greater than zero.

integer percentage = 50; // Percentage to pay creator of inventory.

string creator_to_pay = "Fred Gandt"; // Name of creator to pay percentage. Case Sensitive.

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

///////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////// DON'T EDIT BELOW THIS POINT UNLESS YOU KNOW WHAT YOU'RE DOING ////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////

key creator_to_pay_key = NULL_KEY;

key name_iq = NULL_KEY;

key owner = NULL_KEY;

list inventory = [];

integer search = 0;

list creators = [];

default {

   on_rez(integer param)
   {
       llResetScript();
   }
   changed(integer change)
   {
       if(change & (CHANGED_OWNER | CHANGED_INVENTORY))
       llResetScript();
   }
   state_entry()
   {
       llSetClickAction(CLICK_ACTION_TOUCH);
       owner = llGetOwner();
       if(percentage > 100)
       percentage = 100;
       llOwnerSay("\nClick this object when you have fully loaded the inventory." +
                  "\nYou will be asked to grant permissions." +
                  "\nYou MUST grant them for this script to function.");
   }
   touch_start(integer nd)
   {
       while(nd)
       {
           if(llDetectedKey(--nd) == owner)
           llRequestPermissions(owner, PERMISSION_DEBIT);
       }
   }
   run_time_permissions(integer perm)
   {
       if(perm & PERMISSION_DEBIT)
       {
           llSetPayPrice(PAY_HIDE, [price, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
           llSetClickAction(CLICK_ACTION_PAY);
           integer in = llGetInventoryNumber(INVENTORY_ALL);
           key creator_key = NULL_KEY;
           integer count = 0;
           string name = "";
           do
           {
               if((name = llGetInventoryName(INVENTORY_ALL, count)) != llGetScriptName())
               {
                   inventory += [name];
                   if(llListFindList(creators, [(creator_key = llGetInventoryCreator(name))]) == -1)
                   creators += [creator_key];
               }
           }
           while((++count) < in);
           if(llGetListLength(inventory))
           name_iq = llRequestAgentData(llList2Key(creators, (search = 0)), DATA_NAME);
           else
           llOwnerSay("\nThere is nothing to sell.\nYou'll need to add some inventory.");
       }
       else
       {
           llOwnerSay("\nYou MUST grant permissions for this script to function.");
           llRequestPermissions(owner, PERMISSION_DEBIT);
       }
   }
   dataserver(key q, string data)
   {
       if(q == name_iq)
       {
           if(data == creator_to_pay)
           {
               creator_to_pay_key = llList2Key(creators, search);
               creators = [];
               state shop;
           }
           else if((llGetListLength(creators) - 1) > search)
           name_iq = llRequestAgentData(llList2Key(creators, (++search)), DATA_NAME);
           else
           llOwnerSay("\nThe creator to pay does not match any of the creators of the inventory." +
                      "\nPlease adjust the script appropriately.");
       }
   }

} state shop {

   on_rez(integer param)
   {
       llResetScript();
   }
   changed(integer change)
   {
       if(change & (CHANGED_OWNER | CHANGED_INVENTORY))
       llResetScript();
   }
   money(key id, integer amount)
   {
       if(amount >= price)
       {
           if(amount > price)
           llGiveMoney(id, (amount - price));
           integer cut = llFloor((((float)amount) / 100.0) * ((float)percentage));
           if(percentage && cut)
           llGiveMoney(creator_to_pay_key, cut);
           llGiveInventoryList(id, folder_name, inventory); // Last operation because of its 3 second script delay.
       }
       else
       {
           llGiveMoney(id, amount);
           llInstantMessage(id, ("\nYou paid too little.\nThe cost of this item is " + ((string)price) + "L$"));
       }
   }

}</lsl>

More Scripts...

Free Scripts (content constantly updating)

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 (this page)

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