User:Fred Gandt/Scripts/Continued 5

From Second Life Wiki
< User:Fred Gandt‎ | Scripts
Revision as of 04:15, 21 March 2017 by Fred Gandt (talk | contribs) (cleaning up headings)
Jump to navigation Jump to search
I get in-world very rarely these days. The knock-on effect of this, is that I am not in the best position to keep these scripts updated. Please message me in-world (forwarded to email) if you discover any bugs (that can't be simply fixed), and I'll do my best to find a solution.

My Contributions

If unsure about how to use these scripts

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

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

All my scripts are written for compilation as MONO

More Scripts

Legal Stuff

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

PJIRA Issue Tracker

The issues I have filed on the PJIRA

Tuition

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

Free Scripts

Prim Property Scrubber

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.

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

Bling Scrubber

This is specifically for removing particles and the scripts that set them from objects. It will cure link_sets or single prims. If the option to scrub the scripts is chosen (as well as to scrub the particles) ALL the scripts in the whole object will be removed.

// V1 //

string instructions = "";

integer channel = -9865443;

string scrub = "SCRUB";

string no = "NO";

integer link_num;

Dialog(integer d)
{
    key owner = llGetOwner();
    llListen(channel, "", owner, "");
    if(d)
    llDialog(owner, "\n\n" + instructions + "ARE YOU SURE YOU WANT TO REMOVE ALL SCRIPTS?" + 
                    "CLICKING \"" + no +
                    "\" WILL STILL REMOVE ALL PARTICLES BUT, THEY MIGHT COME BACK.", [scrub, no], channel);
}

default
{
    on_rez(integer param)
    {
        Dialog(1);
    }
    state_entry()
    {
        if((link_num = llGetLinkNumber()) == 1)
        {
            integer i = 2;
            do
            llGiveInventory(llGetLinkKey(i), llGetScriptName());
            while((++i) <= llGetNumberOfPrims());
            instructions = "Open an edit on me and goto your viewer \"Tools\" menu.\n" +
                           "Near the bottom of the menu click \"Set Scripts Running in Selection\".\n" +
                           "Once ALL the scripts are set running, click the \"" + scrub + "\" button.\n\n";
            llOwnerSay("Take then rez me. Follow the instructions given on rez.");
        }
        else if(!link_num)
        Dialog(1);
        else
        Dialog(0);
    }
    listen(integer chan, string name, key id, string msg)
    {
        chan = 0;
        if(msg == scrub)
        {
            string name;
            while((llGetInventoryNumber(INVENTORY_SCRIPT) - 1))
            {
                if((name = llGetInventoryName(INVENTORY_SCRIPT, chan)) != llGetScriptName())
                llRemoveInventory(name);
                else
                chan = 1;
            }
        }
        if(((chan = link_num) == 1))
        {
            do
            llLinkParticleSystem(chan, []);
            while((++chan) <= llGetNumberOfPrims());
        }
        else
        llParticleSystem([]);
        if(link_num < 2)
        llOwnerSay("All done!");
        llRemoveInventory(llGetScriptName());
    }
}

Basic Notecard Readers

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

Cyclically Sequential Lines

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

Random Lines

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

CamHUD

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.

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

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.

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

Simple Profit Share Vendor

  • 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.

// 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$"));
        }
    }
}

Preloading Texture Displayer

Use to display a texture to the public while displaying on a hidden face the next texture to display. Perfect for presentations that require a slideshow. Touch triggered, the textures will be displayed incrementally in alphabetical/numerical order. The script reads the textures from the inventory of the object and reacts only to the owners touch.

// V1 //

integer display_face = 0; // Face to display the texture on.

integer hidden_face = 1; // A face that is hidden that displays the texture to be preloaded to all local viewers.

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////NO NEED TO EDIT ANYTHING BELOW HERE///////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

key owner;

integer tex;

integer noi;

default
{
    on_rez(integer param)
    {
        llResetScript();
    }
    changed(integer change)
    {
        if(change & (CHANGED_INVENTORY | CHANGED_OWNER))
        llResetScript();
    }
    state_entry()
    {
        owner = llGetOwner();
        if((noi = llGetInventoryNumber(INVENTORY_TEXTURE)))
        {
            llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, (tex = 0)), display_face);
            if(noi > 1)
            llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, (++tex)), hidden_face);
        }
    }
    touch_start(integer nd)
    {
        while(nd)
        {
            if((llDetectedKey(--nd) == owner) && (noi > 1))
            {
                llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, tex), display_face);
                if((++tex) == noi)
                tex = 0;
                llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, tex), hidden_face);
            }
        }
    }
}

Analog Clock

Analog clock with hourly chimes (if desired) and Westminster Quarters (also if desired) that by default shows SLT but can, by simply clicking the object, be adjusted to show any global timezone.

  • To change the timezone by touching the clock (not editing the script):
    • Touch the right sade of the face to increment the time by 15 minutes.
    • Touch the left side of the face to decrement the time by 15 minutes.
  • The first script is used to build the object.
  • The second script runs the clock.

Clock Maker

  • Create a link_set of 5 prims.
  • Drop this script on it.
// V2 //

default {
    state_entry() {
        if ( llGetObjectPrimCount( llGetKey() ) == 5 ) {
            llSetLinkPrimitiveParamsFast( 5, [
                    PRIM_MATERIAL, PRIM_MATERIAL_METAL,
                    PRIM_PHYSICS, FALSE,
                    PRIM_TEMP_ON_REZ, FALSE,
                    PRIM_PHANTOM, TRUE,
                    PRIM_SIZE, <0.090000, 0.08000, 0.080000>,
                    PRIM_TYPE, PRIM_TYPE_SPHERE, PRIM_HOLE_DEFAULT, <0.000000, 1.000000, 0.000000>, 0.000000, ZERO_VECTOR, <0.500000, 1.000000, 0.000000>,
                    PRIM_FLEXIBLE, FALSE, FALSE, 0.000000, 0.000000, 0.000000, 0.000000, ZERO_VECTOR,
                    PRIM_POINT_LIGHT, FALSE, ZERO_VECTOR, 0.000000, 0.000000, 0.000000,
                    PRIM_TEXT, "", ZERO_VECTOR, 1.000000,
                    PRIM_NAME, "Spindle",
                    PRIM_DESC, "",
                    PRIM_ROT_LOCAL, <0.000000, 0.707107, 0.000000, 0.707107>,
                    PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_PRIM,
                    PRIM_OMEGA, ZERO_VECTOR, 0.000000, 0.000000,
                    PRIM_POS_LOCAL, <0.000000, 0.000000, 0.010000>,
                    PRIM_SLICE, <0.500000, 1.000000, 0.000000>,
                    PRIM_ALLOW_UNSIT, TRUE,
                    PRIM_SCRIPTED_SIT_ONLY, FALSE,
                    PRIM_SIT_TARGET, FALSE, ZERO_VECTOR, ZERO_ROTATION,
                    PRIM_TEXTURE, ALL_SIDES, TEXTURE_BLANK, <3.100000, 1.000000, 0.000000>, ZERO_VECTOR, 0.000000,
                    PRIM_COLOR, ALL_SIDES, <0.215686, 0.227451, 0.250980>, 1.000000,
                    PRIM_BUMP_SHINY, ALL_SIDES, PRIM_SHINY_LOW, PRIM_BUMP_SIDING,
                    PRIM_FULLBRIGHT, ALL_SIDES, FALSE,
                    PRIM_TEXGEN, ALL_SIDES, PRIM_TEXGEN_DEFAULT,
                    PRIM_GLOW, ALL_SIDES, 0.000000,
                    PRIM_SPECULAR, ALL_SIDES, NULL_KEY, <1.000000, 1.000000, 0.000000>, ZERO_VECTOR, 0.000000, <1.000000, 1.000000, 1.000000>, 51, FALSE,
                    PRIM_NORMAL, ALL_SIDES, NULL_KEY, <1.000000, 1.000000, 0.000000>, ZERO_VECTOR, 0.000000,
                    PRIM_ALPHA_MODE, ALL_SIDES, TRUE, FALSE
                ] + [ PRIM_LINK_TARGET, 4,
                    PRIM_MATERIAL, PRIM_MATERIAL_PLASTIC,
                    PRIM_PHYSICS, FALSE,
                    PRIM_TEMP_ON_REZ, FALSE,
                    PRIM_PHANTOM, TRUE,
                    PRIM_SIZE, <0.020000, 0.800000, 0.020000>,
                    PRIM_TYPE, PRIM_TYPE_BOX, PRIM_HOLE_DEFAULT, <0.375000, 0.875000, 0.000000>, 0.000000, ZERO_VECTOR, <1.000000, 1.000000, 0.000000>, ZERO_VECTOR,
                    PRIM_FLEXIBLE, FALSE, FALSE, 0.000000, 0.000000, 0.000000, 0.000000, ZERO_VECTOR,
                    PRIM_POINT_LIGHT, FALSE, ZERO_VECTOR, 0.000000, 0.000000, 0.000000,
                    PRIM_TEXT, "", ZERO_VECTOR, 1.000000,
                    PRIM_NAME, "Minute hand",
                    PRIM_DESC, "",
                    PRIM_ROT_LOCAL, ZERO_ROTATION,
                    PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_PRIM,
                    PRIM_OMEGA, ZERO_VECTOR, 0.000000, 0.000000,
                    PRIM_POS_LOCAL, <0.000000, 0.000000, 0.030000>,
                    PRIM_SLICE, <0.400000, 0.600000, 0.000000>,
                    PRIM_ALLOW_UNSIT, TRUE,
                    PRIM_SCRIPTED_SIT_ONLY, FALSE,
                    PRIM_SIT_TARGET, FALSE, ZERO_VECTOR, ZERO_ROTATION,
                    PRIM_TEXTURE, ALL_SIDES, TEXTURE_BLANK, <1.000000, 1.000000, 0.000000>, ZERO_VECTOR, 0.000000,
                    PRIM_COLOR, ALL_SIDES, ZERO_VECTOR, 1.000000,
                    PRIM_BUMP_SHINY, ALL_SIDES, PRIM_SHINY_LOW, PRIM_BUMP_NONE,
                    PRIM_FULLBRIGHT, ALL_SIDES, FALSE,
                    PRIM_TEXGEN, ALL_SIDES, PRIM_TEXGEN_DEFAULT,
                    PRIM_GLOW, ALL_SIDES, 0.000000,
                    PRIM_SPECULAR, ALL_SIDES, NULL_KEY, <1.000000, 1.000000, 0.000000>, ZERO_VECTOR, 0.000000, <1.000000, 1.000000, 1.000000>, 51, FALSE,
                    PRIM_NORMAL, ALL_SIDES, NULL_KEY, <1.000000, 1.000000, 0.000000>, ZERO_VECTOR, 0.000000,
                    PRIM_ALPHA_MODE, ALL_SIDES, TRUE, FALSE
                ] + [ PRIM_LINK_TARGET, 3,
                    PRIM_MATERIAL, PRIM_MATERIAL_PLASTIC,
                    PRIM_PHYSICS, FALSE,
                    PRIM_TEMP_ON_REZ, FALSE,
                    PRIM_PHANTOM, TRUE,
                    PRIM_SIZE, <0.010000, 0.700000, 0.020000>,
                    PRIM_TYPE, PRIM_TYPE_BOX, PRIM_HOLE_DEFAULT, <0.375000, 0.875000, 0.000000>, 0.000000, ZERO_VECTOR, <1.000000, 1.000000, 0.000000>, ZERO_VECTOR,
                    PRIM_FLEXIBLE, FALSE, FALSE, 0.000000, 0.000000, 0.000000, 0.000000, ZERO_VECTOR,
                    PRIM_POINT_LIGHT, FALSE, ZERO_VECTOR, 0.000000, 0.000000, 0.000000,
                    PRIM_TEXT, "", ZERO_VECTOR, 1.000000,
                    PRIM_NAME, "Second hand",
                    PRIM_DESC, "",
                    PRIM_ROT_LOCAL, ZERO_ROTATION,
                    PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_PRIM,
                    PRIM_OMEGA, ZERO_VECTOR, 0.000000, 0.000000,
                    PRIM_POS_LOCAL, <0.000000, 0.000000, 0.040000>,
                    PRIM_SLICE, <0.400000, 0.600000, 0.000000>,
                    PRIM_ALLOW_UNSIT, TRUE,
                    PRIM_SCRIPTED_SIT_ONLY, FALSE,
                    PRIM_SIT_TARGET, FALSE, ZERO_VECTOR, ZERO_ROTATION,
                    PRIM_TEXTURE, ALL_SIDES, TEXTURE_BLANK, <1.000000, 1.000000, 0.000000>, ZERO_VECTOR, 0.000000,
                    PRIM_COLOR, ALL_SIDES, <0.501961, 0.000000, 0.000000>, 1.000000,
                    PRIM_BUMP_SHINY, ALL_SIDES, PRIM_SHINY_LOW, PRIM_BUMP_NONE,
                    PRIM_FULLBRIGHT, ALL_SIDES, FALSE,
                    PRIM_TEXGEN, ALL_SIDES, PRIM_TEXGEN_DEFAULT,
                    PRIM_GLOW, ALL_SIDES, 0.000000,
                    PRIM_SPECULAR, ALL_SIDES, NULL_KEY, <1.000000, 1.000000, 0.000000>, ZERO_VECTOR, 0.000000, <1.000000, 1.000000, 1.000000>, 51, FALSE,
                    PRIM_NORMAL, ALL_SIDES, NULL_KEY, <1.000000, 1.000000, 0.000000>, ZERO_VECTOR, 0.000000,
                    PRIM_ALPHA_MODE, ALL_SIDES, TRUE, FALSE
                ] + [ PRIM_LINK_TARGET, 2,
                    PRIM_MATERIAL, PRIM_MATERIAL_PLASTIC,
                    PRIM_PHYSICS, FALSE,
                    PRIM_TEMP_ON_REZ, FALSE,
                    PRIM_PHANTOM, TRUE,
                    PRIM_SIZE, <0.040000, 0.600000, 0.020000>,
                    PRIM_TYPE, PRIM_TYPE_BOX, PRIM_HOLE_DEFAULT, <0.375000, 0.875000, 0.000000>, 0.000000, ZERO_VECTOR, <1.000000, 1.000000, 0.000000>, ZERO_VECTOR,
                    PRIM_FLEXIBLE, FALSE, FALSE, 0.000000, 0.000000, 0.000000, 0.000000, ZERO_VECTOR,
                    PRIM_POINT_LIGHT, FALSE, ZERO_VECTOR, 0.000000, 0.000000, 0.000000,
                    PRIM_TEXT, "", ZERO_VECTOR, 1.000000,
                    PRIM_NAME, "Hour hand",
                    PRIM_DESC, "",
                    PRIM_ROT_LOCAL, ZERO_ROTATION,
                    PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_PRIM,
                    PRIM_OMEGA, ZERO_VECTOR, 0.000000, 0.000000,
                    PRIM_POS_LOCAL, <0.000000, 0.000000, 0.020000>,
                    PRIM_SLICE, <0.400000, 0.600000, 0.000000>,
                    PRIM_ALLOW_UNSIT, TRUE,
                    PRIM_SCRIPTED_SIT_ONLY, FALSE,
                    PRIM_SIT_TARGET, FALSE, ZERO_VECTOR, ZERO_ROTATION,
                    PRIM_TEXTURE, ALL_SIDES, TEXTURE_BLANK, <1.000000, 1.000000, 0.000000>, ZERO_VECTOR, 0.000000,
                    PRIM_COLOR, ALL_SIDES, ZERO_VECTOR, 1.000000,
                    PRIM_BUMP_SHINY, ALL_SIDES, PRIM_SHINY_LOW, PRIM_BUMP_NONE,
                    PRIM_FULLBRIGHT, ALL_SIDES, FALSE,
                    PRIM_TEXGEN, ALL_SIDES, PRIM_TEXGEN_DEFAULT,
                    PRIM_GLOW, ALL_SIDES, 0.000000,
                    PRIM_SPECULAR, ALL_SIDES, NULL_KEY, <1.000000, 1.000000, 0.000000>, ZERO_VECTOR, 0.000000, <1.000000, 1.000000, 1.000000>, 51, FALSE,
                    PRIM_NORMAL, ALL_SIDES, NULL_KEY, <1.000000, 1.000000, 0.000000>, ZERO_VECTOR, 0.000000,
                    PRIM_ALPHA_MODE, ALL_SIDES, TRUE, FALSE
                ] + [ PRIM_LINK_TARGET, 1,
                    PRIM_MATERIAL, PRIM_MATERIAL_METAL,
                    PRIM_PHYSICS, FALSE,
                    PRIM_TEMP_ON_REZ, FALSE,
                    PRIM_PHANTOM, TRUE,
                    PRIM_SIZE, <1.000000, 1.000000, 0.020000>,
                    PRIM_ROTATION, <0.707107, -0.000000, -0.000000, 0.707107>,
                    PRIM_TYPE, PRIM_TYPE_CYLINDER, PRIM_HOLE_DEFAULT, <0.000000, 1.000000, 0.000000>, 0.000000, ZERO_VECTOR, <0.950000, 0.950000, 0.000000>, ZERO_VECTOR,
                    PRIM_FLEXIBLE, FALSE, FALSE, 0.000000, 0.000000, 0.000000, 0.000000, ZERO_VECTOR,
                    PRIM_POINT_LIGHT, FALSE, ZERO_VECTOR, 0.000000, 0.000000, 0.000000,
                    PRIM_TEXT, "", ZERO_VECTOR, 1.000000,
                    PRIM_NAME, "Analog clock",
                    PRIM_DESC, "4 prim analog clock with hourly chimes",
                    PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_PRIM,
                    PRIM_OMEGA, ZERO_VECTOR, 0.000000, 0.000000,
                    PRIM_SLICE, <0.000000, 1.000000, 0.000000>,
                    PRIM_ALLOW_UNSIT, TRUE,
                    PRIM_SCRIPTED_SIT_ONLY, FALSE,
                    PRIM_SIT_TARGET, FALSE, ZERO_VECTOR, ZERO_ROTATION,
                    PRIM_TEXTURE, 0, "ecf785e7-4cf6-9f95-6292-40061bdddeed", <0.700000, 0.700000, 0.000000>, ZERO_VECTOR, 0.000000,
                    PRIM_TEXTURE, 1, TEXTURE_BLANK, <50.000000, 1.000000, 0.000000>, ZERO_VECTOR, 0.000000,
                    PRIM_TEXTURE, 2, TEXTURE_BLANK, <1.000000, 1.000000, 0.000000>, ZERO_VECTOR, 0.000000,
                    PRIM_COLOR, 0, <0.674510, 0.674510, 0.725490>, 1.000000,
                    PRIM_COLOR, 1, ZERO_VECTOR, 1.000000,
                    PRIM_COLOR, 2, ZERO_VECTOR, 1.000000,
                    PRIM_BUMP_SHINY, 0, PRIM_SHINY_HIGH, PRIM_BUMP_BRIGHT,
                    PRIM_BUMP_SHINY, 1, PRIM_SHINY_LOW, PRIM_BUMP_NONE,
                    PRIM_BUMP_SHINY, 2, PRIM_SHINY_LOW, PRIM_BUMP_NONE,
                    PRIM_FULLBRIGHT, ALL_SIDES, FALSE,
                    PRIM_TEXGEN, ALL_SIDES, PRIM_TEXGEN_DEFAULT,
                    PRIM_GLOW, ALL_SIDES, 0.000000,
                    PRIM_SPECULAR, ALL_SIDES, NULL_KEY, <1.000000, 1.000000, 0.000000>, ZERO_VECTOR, 0.000000, <1.000000, 1.000000, 1.000000>, 51, FALSE,
                    PRIM_NORMAL, ALL_SIDES, NULL_KEY, <1.000000, 1.000000, 0.000000>, ZERO_VECTOR, 0.000000,
                    PRIM_ALPHA_MODE, ALL_SIDES, TRUE, FALSE
                ] );
            llRemoveInventory( llGetScriptName() );
        } else {
            llOwnerSay( "Read the instructions" );
        }
    }
}

Clock Movement

  • Drop this script onto the clock object.
  • As soon as the script runs it will start displaying the time SLT (unless you change the timezone value).
// V4 //

// The UUIDs of chime sounds at 4 different pitches.
key bell_b = "729a4e57-0628-f253-bb34-ec649b896b77";
key bell_e = "2cfd2002-abc9-f5eb-e137-1b2cc6c2f3bb";
key bell_f_sharp = "6b8f3015-c4c7-83d5-3429-2e1fd2ebd577";
key bell_g_sharp = "cdab652c-6488-2ead-7abc-c52351bef11d";

// Volume of chime. 1.0 is maximum.
float chime_volume = 1.0;

// Set to FALSE for no chimes.
integer chimes = TRUE;

// Set to FALSE for no quarterly chimes.
integer quarterly_chimes = TRUE;

// PDT. PST is -8.0 and 0.0 will be GMT/UTC.
float timezone = -7.0;

///////////////////////// IF YOU EDIT BELOW THIS LINE THE SCRIPT WILL EXPLODE ///////////////////////////

// Said to the owner if the object isn't built correctly.
string build_advice = "This script requires that the object has at least 4 prims.
There should be 3 child prims named: \"Hour hand\", \"Minute hand\" and \"Second hand\",
and at least one other prim that is the root.";

// Used to store the link number's of the hands.
integer second_hand_link;
integer minute_hand_link;
integer hour_hand_link;

// A few numerical values that are repeatedly used.
integer twelve_hours = 43200;
integer one_hour = 3600;
integer fifteen_minutes = 900;

// Used to store the timezone offset converted to seconds.
integer tz;

// The full order in which the Westminster Quarters are played.
list westminster_quarters = [ bell_g_sharp, bell_f_sharp, bell_e, bell_b,
                              bell_e, bell_g_sharp, bell_f_sharp, bell_b,
                              bell_e, bell_f_sharp, bell_g_sharp, bell_e,
                              bell_g_sharp, bell_e, bell_f_sharp, bell_b,
                              bell_b, bell_f_sharp, bell_g_sharp, bell_e,
// Plus one null key used to rest between each part of each quarter.
                              NULL_KEY ];

// The seconds past each hour at which each quarter is played.
list quarters_lookup = [ fifteen_minutes, 1800, 2700, 3585 ];

// The parts of the Westminster Quarters to play each quarter.
list quarters_lookdown = [ "0, 1, 2, 3",
                           "4, 5, 6, 7, 20, 8, 9, 10, 11",
                           "12, 13, 14, 15, 20, 16, 17, 18, 19, 20, 0, 1, 2, 3",
                           "4, 5, 6, 7, 20, 8, 9, 10, 11, 20, 12, 13, 14, 15, 20, 16, 17, 18, 19" ];

// Used to remember the above parts when converted from strings to lists.
list quartermaster;

// Several variables used to monitor the flow of the Westminster Quarters.
integer tock;
integer qm_length;
integer westmindex;
integer current_quarter;
integer hung_drawn_and_quartered = FALSE;

// Used to store the owner's UUID.
key owner;

// Function to handle all chiming.
chime( integer secs ) {
    integer current_second = secs % one_hour; // Temporarily store the seconds past the hour,
    integer current_hour = secs / one_hour; // and the current hour.
    if ( quarterly_chimes ) { // If quarterly chimes are to be played,
        if ( hung_drawn_and_quartered ) { // and the necessary groundwork has been done,
            if ( westmindex < qm_length ) { // and we're supposed to be playing a sound:
                // Work out which sound we're supposed to be playing, based on the current data,
                key bell = llList2Key( westminster_quarters, llList2Integer( quartermaster, westmindex++ ) );
                if ( bell ) { // and if it's a bell sound, and not a rest,
                    llTriggerSound( bell, chime_volume ); // chime!
                }
            } else { // If we're not supposed to be playing a sound,
                hung_drawn_and_quartered = FALSE; // we must have finished this quarter,
                llSetTimerEvent( 1.0 ); // so go back to normal speed.
            }
        } else { // If the necessary groundwork has not been done:
            // Establish if we should be playing a quarter by comparing the current second
            current_quarter = llListFindList( quarters_lookup, [ current_second ] ); // to the seconds at each quarter.
            if ( ~current_quarter ) { // and if we should be playing a quarter:
                // Fetch the appropriate string of indexes, and convert it to a list,
                quartermaster = llCSV2List( llList2String( quarters_lookdown, current_quarter ) );
                qm_length = llGetListLength( quartermaster ); // establish how long that list is,
                hung_drawn_and_quartered = TRUE; // switch on our indicator that we should be playing quarters,
                westmindex = 0; // reset our counter,
                llSetTimerEvent( 0.5 ); // and speed up the clock's movement.
            }
        }
    }
    if ( current_second < current_hour ) { // If the current second is less than the current hour.
        llTriggerSound( bell_b, chime_volume ); // Chime!
    }
}

// Function called per timer event.
tick() {
    integer seconds = ( integer )llGetGMTclock() + tz; // Seconds equals seconds past midnight GMT/UTC plus timezone offset.
    // If the clock movement has been sped up to play the Westminster Quarters, only move the hands every other tick.
    if ( !hung_drawn_and_quartered || ( tock = !tock ) ) {
        if ( seconds > twelve_hours ) { // If it's past noon,
            seconds -= twelve_hours; // turn back time by twelve hours.
        }
        // Rotate all the hands to show the current time.
        llSetLinkPrimitiveParamsFast( second_hand_link, [ PRIM_ROT_LOCAL, llEuler2Rot( <0.0, 0.0, ( seconds * -6.0 )> * DEG_TO_RAD ),
                    PRIM_LINK_TARGET, minute_hand_link,   PRIM_ROT_LOCAL, llEuler2Rot( <0.0, 0.0, ( seconds * -0.1 )> * DEG_TO_RAD ),
                    PRIM_LINK_TARGET, hour_hand_link,     PRIM_ROT_LOCAL, llEuler2Rot( <0.0, 0.0, ( seconds * -0.008333 )> * DEG_TO_RAD ) ] );
    }
    if ( chimes ) { // If we should be playing chimes,
        chime( seconds ); // call the chime function and tell it what the time is.
    }
}

// Function to convert a negative timezone into a positive one.
backToTheFuture() {
    if ( tz < 0 ) { // If tz is negative,
        tz += twelve_hours; // make it positive.
    }
}

default {
    // Triggered when many different things that affect the object or script are changed.
    changed( integer change ) {
        if ( change & ( CHANGED_LINK | CHANGED_OWNER ) ) {
            llResetScript(); // if the way the object is built or the owner has changed.
        }
    }
    // Triggered when we enter our parent state.
    state_entry() {
        owner = llGetOwner(); // Store the owner's UUID.
        integer nol = llGetObjectPrimCount( llGetKey() ); // Establish how many prims are in the object,
        if ( nol > 3 ) { // and if the object has at least four prims,
            string link_name; // use this to remember their names,
            while ( nol > 1 ) { // whilst ignoring the root,
                link_name = llGetLinkName( nol ); // and by reading their names,
                if ( link_name == "Second hand" ) {
                    second_hand_link = nol; // establish which prims are the hands.
                } else if ( link_name == "Minute hand" ) {
                    minute_hand_link = nol;
                } else if ( link_name == "Hour hand" ) {
                    hour_hand_link = nol;
                }
                --nol; // Count backwards from the last link.
            }
            if ( hour_hand_link && minute_hand_link && second_hand_link ) { // If the object is built correctly:
                tz = ( integer )( timezone * one_hour ); // Convert timezone hours to seconds,
                backToTheFuture(); // Make sure the timezone is positive.
                llSetTimerEvent( 1.0 ); // Start the clock.
            } else { // Otherwise,
                llOwnerSay( build_advice ); // tell the owner what's wrong.
            }
        } else { // Otherwise,
            llOwnerSay( build_advice ); // tell the owner what's wrong.
        }
    }
    // Triggered when a touch (mouse click or menu selected) is started on the object containing this script.
    touch_start( integer nd ) {
        while ( nd ) { // For every detected touch,
            if ( llDetectedKey( --nd ) == owner ) { // check if the clock's owner is touching it,
                // and if the clock's face was touched,
                if ( llDetectedLinkNumber( nd ) == 1 && !llDetectedTouchFace( nd ) ) {
                    vector UV = llDetectedTouchUV( nd ); // find out where the face was touched.
                    if ( UV.x > 0.5 ) { // If the right side was touched,
                        tz += fifteen_minutes; // increase timezone by quarter of an hour.
                    } else { // Otherwise,
                        tz -= fifteen_minutes; // decrease timezone by quarter of an hour.
                    }
                    if ( tz == twelve_hours ) { // If timezone equals +twelve hours,
                        tz = 0; // reset timezone to zero.
                    }
                    backToTheFuture(); // Make sure the timezone is positive.
                }
            }
        }
    }
    // Triggered at whatever interval was last set by a call to llSetTimerEvent().
    timer() {
        tick(); // Call the function that handles our ticks.
    }
}

One Prim Analog Clock

  • Basically the same instructions as above, except use only one prim.
  • No chimes or second hand.

Clock Maker

// V1 //

default {
    state_entry() {
        if ( llGetObjectPrimCount( llGetKey() ) == 1 ) {
            llSetLinkPrimitiveParamsFast( LINK_THIS, [
                PRIM_MATERIAL, PRIM_MATERIAL_WOOD,
                PRIM_PHYSICS, FALSE,
                PRIM_TEMP_ON_REZ, FALSE,
                PRIM_PHANTOM, FALSE,
                PRIM_SIZE, <0.010000, 0.500000, 0.500000>,
                PRIM_ROTATION, <0.006886, -0.006422, 0.682003, 0.731288>,
                PRIM_TYPE, PRIM_TYPE_TUBE, PRIM_HOLE_DEFAULT, <0.000000, 1.000000, 0.000000>, 0.870000, ZERO_VECTOR, <1.000000, 0.500000, 0.000000>, ZERO_VECTOR, <0.260000, 1.000000, 0.000000>, ZERO_VECTOR, 1.000000, 0.000000, 0.000000,
                PRIM_FLEXIBLE, FALSE, FALSE, 0.000000, 0.000000, 0.000000, 0.000000, ZERO_VECTOR,
                PRIM_POINT_LIGHT, FALSE, ZERO_VECTOR, 0.000000, 0.000000, 0.000000,
                PRIM_TEXT, "", ZERO_VECTOR, 1.000000,
                PRIM_NAME, "One prim analog clock",
                PRIM_DESC, "",
                PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_PRIM,
                PRIM_OMEGA, ZERO_VECTOR, 0.000000, 0.000000,
                PRIM_SLICE, <0.260000, 1.000000, 0.000000>,
                PRIM_ALLOW_UNSIT, TRUE,
                PRIM_SCRIPTED_SIT_ONLY, FALSE,
                PRIM_SIT_TARGET, FALSE, ZERO_VECTOR, ZERO_ROTATION,
                PRIM_TEXTURE, 0, "6d4b097d-a29e-df77-1ff3-1b6beb505f83", <1.000000, 1.000000, 0.000000>, <1.000000, 0.000000, 0.000000>, 0.000000,
                PRIM_TEXTURE, 1, TEXTURE_PLYWOOD, <1.000000, 1.000000, 0.000000>, ZERO_VECTOR, 0.000000,
                PRIM_TEXTURE, 2, "f99cd171-c605-920f-2d1a-4ffcfb35664a", <1.000000, 1.000000, 0.000000>, ZERO_VECTOR, 0.000000,
                PRIM_TEXTURE, 3, "42bf069c-ec10-1965-6238-935c3ff16db8", <1.000000, 1.000000, 0.000000>, ZERO_VECTOR, 0.000000,
                PRIM_TEXTURE, 4, "f99cd171-c605-920f-2d1a-4ffcfb35664a", <1.000000, 1.000000, 0.000000>, ZERO_VECTOR, 0.000000,
                PRIM_TEXTURE, 5, "a25bebc8-4739-453d-d44e-fc522cf95488", <0.052000, 2.800000, 0.000000>, ZERO_VECTOR, 0.000000,
                PRIM_COLOR, 0, ZERO_VECTOR, 1.000000,
                PRIM_COLOR, 1, <1.000000, 1.000000, 1.000000>, 1.000000,
                PRIM_COLOR, 2, <1.000000, 1.000000, 1.000000>, 1.000000,
                PRIM_COLOR, 3, ZERO_VECTOR, 1.000000,
                PRIM_COLOR, 4, <1.000000, 1.000000, 1.000000>, 1.000000,
                PRIM_COLOR, 5, <1.000000, 1.000000, 1.000000>, 1.000000,
                PRIM_BUMP_SHINY, 0, PRIM_SHINY_NONE, PRIM_BUMP_NONE,
                PRIM_BUMP_SHINY, 1, PRIM_SHINY_NONE, PRIM_BUMP_NONE,
                PRIM_BUMP_SHINY, 2, PRIM_SHINY_NONE, PRIM_BUMP_NONE,
                PRIM_BUMP_SHINY, 3, PRIM_SHINY_NONE, PRIM_BUMP_NONE,
                PRIM_BUMP_SHINY, 4, PRIM_SHINY_NONE, PRIM_BUMP_NONE,
                PRIM_BUMP_SHINY, 5, PRIM_SHINY_MEDIUM, PRIM_BUMP_NONE,
                PRIM_FULLBRIGHT, ALL_SIDES, FALSE,
                PRIM_TEXGEN, 0, PRIM_TEXGEN_PLANAR,
                PRIM_TEXGEN, 1, PRIM_TEXGEN_DEFAULT,
                PRIM_TEXGEN, 2, PRIM_TEXGEN_DEFAULT,
                PRIM_TEXGEN, 3, PRIM_TEXGEN_PLANAR,
                PRIM_TEXGEN, 4, PRIM_TEXGEN_DEFAULT,
                PRIM_TEXGEN, 5, PRIM_TEXGEN_DEFAULT,
                PRIM_GLOW, ALL_SIDES, 0.000000,
                PRIM_SPECULAR, ALL_SIDES, NULL_KEY, <1.000000, 1.000000, 0.000000>, ZERO_VECTOR, 0.000000, <1.000000, 1.000000, 1.000000>, 51, FALSE,
                PRIM_NORMAL, ALL_SIDES, NULL_KEY, <1.000000, 1.000000, 0.000000>, ZERO_VECTOR, 0.000000,
                PRIM_ALPHA_MODE, ALL_SIDES, TRUE, FALSE
            ] );
            llRemoveInventory( llGetScriptName() );
        } else {
            llOwnerSay( "Read the instructions" );
        }
    }
}

Clock Movement

// V1 //

key hour_hand = "5102a720-437d-9a59-1523-2bbd8d74ceea"; // PNG texture of an hour hand on a transparent background.
key min_hand = "28c3f7ba-6edd-67e7-b387-52b0da37053f"; // PNG texture of a minute hand on a transparent background.

integer timezone = -8; // Offset in hours from GMT. -8 is SLT.

float update_rate = 60.0; // The number of seconds between each display update.
// It is kinder to the region running this script, to run the timer slower.
// Since there is no second hand, there's no need to update evry second.
// Set to 60.0, the hands update once a minute.

//////////////////////////////
////// System Variables //////

integer twelve_hours = 43200;
integer one_hour = 3600;

tick() {
    float seconds = llGetGMTclock() + timezone;
    llSetLinkPrimitiveParamsFast( LINK_THIS, [
        PRIM_TEXTURE, 3, min_hand, <1.0, 1.0, 0.0>, ZERO_VECTOR, ( seconds * -0.1 ) * DEG_TO_RAD,
        PRIM_TEXTURE, 0, hour_hand, <1.0, 1.0, 0.0>, <1.0, 0.0, 0.0>, ( seconds * -0.008333 ) * DEG_TO_RAD
    ] );
}
 
default {
    on_rez( integer param ) {
        llResetScript();
    }
    state_entry() {
        timezone *= one_hour;
        tick();
        llSetTimerEvent( update_rate );
    }
    timer() {
        tick();
    }
    touch_start( integer nd ) {
        while ( nd ) {
            if ( llDetectedKey( --nd ) == llGetOwner() ) {
                timezone += one_hour;
                if ( timezone == twelve_hours ) {
                    timezone = 0;
                }
                tick();
            }
        }
    }
}

Shutter Door

Retracting door. Acts like a security shutter. The textures are offset to follow the movement so as the shutter folds away or folds out the texture stays in the correct place. This first version may be a little ropey but I got bored testing. I'll work on an update later.

Create Basic Shutter

Drop this script on a fresh prim to create a basic shutter shape with a simple shutter texturing provided by using the "Siding" bump map.

// V1 //

default
{
    state_entry()
    {
        llSetPrimitiveParams([7, <4.0, 6.0, 0.01>,
                              8, <0.0, 0.707107, -0.707107, 0.0>,
                              9, 0, 0, <0.375, 0.875, 0.0>, 0.0, <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", <6.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.570796,
                              18, -1, <1.0, 1.0, 1.0>, 1.0,
                              19, 0, 1, 13,
                              19, 1, 1, 0,
                              19, 2, 1, 0,
                              19, 3, 1, 0,
                              19, 4, 1, 13,
                              19, 5, 1, 0,
                              19, 6, 1, 0,
                              25, -1, 0.02]);
        llRemoveInventory(llGetScriptName()); // Self deleting script.
    }
}

Shutter Script

This script actually operates the door (by touch).

// V2 //

float delay = 10.0; // Seconds before auto closure. Set to zero to disable.

float volume = 1.0; // Volume for sounds. 0.0 to 1.0

float speed = 0.02; // Speed of shutter action. The larger the figure the faster the action.

key texture = TEXTURE_BLANK; // UUID of the texture to use on the two most prominent faces.

key start = "03127ba7-9dbb-b6ab-0622-dcf8f1cd841a"; // UUID of initializing sound.

key loop = "55fc1f41-9b74-bc66-8ad5-89b6c489851c"; // UUID of retraction loop sound.

key end = "c7579f2c-6a23-f2b6-8d82-84a052b1bc30"; // UUID of termination sound.

integer open;

float rot;

float Y;

OperateDoor(integer i)
{
    vector v = llGetScale();
    float y = v.y;
    llTriggerSound(start, volume);
    llLoopSound(loop, volume);
    if(i)
    {
        Y = y;
        float o = 1.0;
        while(y > speed)
        {
            llSetLinkPrimitiveParamsFast(-4, [PRIM_SIZE, <v.x, (y -= speed), v.z>,
                                              PRIM_TEXTURE, 4, texture, <y,1.0,0.0>, <(o -= (speed / 2)),0.0,0.0>, rot,
                                              PRIM_TEXTURE, 0, texture, <y,1.0,0.0>, <(-o),0.0,0.0>, rot]);
            if(o < (-1.0 + (speed / 2)))
            o = 1.0;
        }
        llSetTimerEvent(delay);
    }
    else
    {
        llSetTimerEvent(0.0);
        float o = 0.0;
        while(y < Y)
        {
            llSetLinkPrimitiveParamsFast(-4, [PRIM_SIZE, <v.x, (y += speed), v.z>,
                                              PRIM_TEXTURE, 4, texture, <y,1.0,0.0>, <(o += (speed / 2)),0.0,0.0>, rot,
                                              PRIM_TEXTURE, 0, texture, <y,1.0,0.0>, <(-o),0.0,0.0>, rot]);
            if(o > (1 - (speed / 2)))
            o = 0.0;
        }
    }
    llPlaySound(end, volume);
}

default
{
    state_entry()
    {
        rot = (90.0 * DEG_TO_RAD);
    }
    touch_start(integer nd)
    {
        OperateDoor((open = (!open)));
    }
    timer()
    {
        OperateDoor((open = 0));
    }
}

More Scripts...

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