Smooth Swing Door 2.0

From Xugu Madison:

// $Id: smooth swing door.lsl 25 2009-08-14 21:53:09Z jrn $
// Smooth swing door, with access control. Control starts at the default state, which
// attempts to load the configuration from the notecard "Configuration" in prim inventory.
// It then passes control along to read_whitelist, then read_blacklist,
// then read_managers, which read in the access control list. After the
// access control lists are loaded, control passes to the setup_door state
// which provides final validation of the door configuration before passing
// to the closed state.
//
// There are then 6 states the door moves between:
//
// closed - indicating the door is closed and unlocked
// open - indicating the door is oepn and unlocked
// swinging - the door is swinging from closed to open
// swinging - the door is swinging from open to closed
// locked_closed - locked in the closed position
// locked_open - locked in the open position ("latched")

// Constants

list CONFIGURATION_NOTECARDS = ["Configuration", "Whitelist", "Blacklist", "Managers"];

list NOTECARD_SEPARATORS = ["="];
list NOTECARD_SPACERS = [];

// These are just defaults, and should be changed from the notecard

list g_Whitelist;
list g_Managers;
list g_Blacklist;

integer g_AllowEveryone;
integer g_AllowGroup;

float g_AutoClose; // Seconds before the door auto-closes
float g_SwingTime; // Seconds for the door to swing from closed to open or back again
integer g_SwingDegrees; // Degrees
vector g_SwingVector;

integer g_ListenChannel; // >= 0 to activate listening

float g_SoundVolume; 
integer g_ChimeActive;
string g_ChimeSoundName;
string g_ClosingSoundName;
string g_LockedSoundName;
string g_OpeningSoundName;
string g_UnlockedSoundName;

// These hold state that needs global access

// 0-4, referring to configuration, whitelist, blacklist and managerlist
// loading.
integer g_ConfigurationStage;

rotation g_ClosedRot;
rotation g_OpenRot;
vector g_UpAxis;

integer g_IsClosed = TRUE;
integer g_IsLocked = FALSE;

integer g_NotecardLine;
key g_NotecardQuery;

// Returns whether the given avatar with UIID "detectedKey" and name
// "detectedName" has permission to open/close this door. "detectedGroup"
// indicates if the avatar has the same ACTIVE group as the group this
// door belongs to (TRUE or FALSE).
integer hasAccess(key detectedKey, string detectedName, integer detectedGroup)
{
    if (detectedKey == llGetOwner())
    {
        return TRUE;
    }
    
    if (llListFindList(g_Managers, [detectedName]) >= 0)
    {
        return TRUE;
    }
    
    if (g_IsLocked)
    {
        return FALSE;
    }

    if (llListFindList(g_Whitelist, [detectedName]) >= 0)
    {
        return TRUE;
    }
            
    if (llListFindList(g_Blacklist, [detectedName]) >= 0)
    {
        return FALSE;
    }
            
    if (g_AllowEveryone)
    {
        return TRUE;
    }
            
    if (g_AllowGroup &&
        detectedGroup)
    {
        return TRUE;
    }
    
    return FALSE;
}

// Parses the configuration as it's loaded from the default state.
// Lines starting with the '#' character are assumed to be comments.
// All other lines are broken into two parts around the '=' character
// and then evaluated as a key-value pair.
parseConfigurationLine(string data)
{
    list parts;
    string name;
    string rawValue;
    string value;
    
    if (data == "" ||
        llGetSubString(data, 0, 0) == "#")
    {
        // Comment, ignore
        return;
    }
    
    parts = llParseString2List(data, NOTECARD_SEPARATORS, NOTECARD_SPACERS);
    if (llGetListLength(parts) <2)
    {
        // Ignore value
        return;
    }
    
    name = llStringTrim(llToLower(llList2String(parts, 0)), STRING_TRIM);
    rawValue = llList2String(parts, 1);
    value = llStringTrim(llToLower(rawValue), STRING_TRIM);
    
    if (name == "access")
    {
        if (value == "owner")
        {
            g_AllowEveryone = FALSE;
            g_AllowGroup = FALSE;
        }
        else if (value == "group")
        {
            g_AllowEveryone = FALSE;
            g_AllowGroup = TRUE;
        }
        else if (value == "everyone" || value == "all")
        {
            g_AllowEveryone = TRUE;
            g_AllowGroup = TRUE;
        } else {
            llOwnerSay("Unknown access type \""
                + value + "\"; valid values are \"owner\", \"group\" or \"everyone\".");
        }
    }
    else if (name == "auto_close")
    {
        g_AutoClose = (float)value;
    }
    else if (name == "chime_name")
    {
        g_ChimeSoundName = value;
    }
    else if (name == "chime_active") 
    {
        if (value == "false" ||
            value == "no")     {
            g_ChimeActive = FALSE;
        }
        else
        {
            g_ChimeActive = TRUE;
        }
    }
    else if (name == "closing_sound_name")
    {
        if (llGetInventoryType(rawValue) != INVENTORY_SOUND)
        {
            llOwnerSay("Closing sound \""
                + rawValue + "\" specified in configuration is either missing from prim inventory, or not a sound.");
        }
        else
        {
            g_ClosingSoundName = rawValue;
        }
    }
    else if (name == "listen_channel")
    {
        g_ListenChannel = (integer)value;
    }
    else if (name == "locked_sound_name")
    {
        if (llGetInventoryType(rawValue) !=  INVENTORY_SOUND)
        {
            llOwnerSay("Locked sound \""
                + rawValue + "\" specified in configuration is either missing from prim inventory, or not a sound.");
        }
        else
        {
            g_LockedSoundName = rawValue;
        }
    }
    else if (name == "opening_sound_name")
    {
        if (llGetInventoryType(rawValue) != INVENTORY_SOUND)
        {
            llOwnerSay("Opening sound \""
                + rawValue + "\" specified in configuration is either missing from prim inventory, or not a sound.");
        }
        else
        {
            g_OpeningSoundName = rawValue;
        }
    }
    else if (name == "sound_volume")
    {
        g_SoundVolume = (float)value;
    }
    else if (name == "swing_degrees")
    {
        g_SwingDegrees = (integer)value;
        if (g_SwingDegrees < -360 ||
            g_SwingDegrees > 360)
        {
            llOwnerSay("Swing degrees must be between -360 and 360 degrees, reverting to 90 degrees.");
            g_SwingDegrees = 90;
        }
    }
    else if (name == "swing_time")
    {
        g_SwingTime = (float)value;
        if (g_SwingTime <0.1)
        {
            llOwnerSay("Swing time must be at least 0.1 seconds, reverting to default of 1.5 seconds.");
            g_SwingTime = 1.5;
        }
    }
    else if (name == "unlocked_sound_name")
    {
        if (llGetInventoryType(rawValue) !=  INVENTORY_SOUND)
        {
            llOwnerSay("Unlocked sound \""
                + rawValue + "\" specified in configuration is either missing from prim inventory, or not a sound.");
        }
        else
        {
            g_UnlockedSoundName = rawValue;
        }
    }
    else
    {
        llOwnerSay("Unknown parameter \""
            + name + "\"; valid names are; access, auto_close, listen_channel, chime_active, chime_name, closing_sound_name, locked_sound_name, opening_sound_name, sound_volume, swing_degrees, swing_time, time_to_close and unlocked_sound_name.");
    }    
    
    return;
}

// Wipes the configuration, cancels any configuration load in progress, and
// starts loading the configuration afresh. Intended to be called only from
// the load_configuration state. Returns TRUE if configuration load was started
// successfully, FALSE otherwise.
integer reloadConfiguration()
{
    // We clear all existing configuration data before attempting to load
    // the new one.
    g_Whitelist = [];
    g_Managers = [];
    g_Blacklist = [];

    g_AllowEveryone = FALSE;
    g_AllowGroup = FALSE;

    g_AutoClose = 3.0; // Seconds before the door auto-closes
    g_SwingTime = 1.0; // Seconds
    g_SwingDegrees = 90; // Degrees
    g_SwingVector;

    g_ListenChannel = -1; // >= 0 to activate listening

    g_SoundVolume = 0.8; 
    g_ChimeActive = TRUE;
    g_ChimeSoundName = "Door bell";
    g_ClosingSoundName = "Door closing";
    g_LockedSoundName = "Door locked";
    g_OpeningSoundName = "Door opening";
    g_UnlockedSoundName = "Door unlocked";
    
    g_NotecardLine = 0;
    
    integer notecardCount = llGetListLength(CONFIGURATION_NOTECARDS);
    
    for (g_ConfigurationStage = 0; g_ConfigurationStage  0.0 &&
        g_ChimeSoundName != "")
        {
            llTriggerSound(g_ChimeSoundName, g_SoundVolume);
        }
    }
}

// Used to update the white/black lists on the fly from chat commands.
// Accepts commands "show", "add" or "remove", with the last two
// to be followed by an avatar name.
list updateList(key id, list modifyList, string message)
{
    list parts = llParseString2List(message, [" "], []);
    integer partsLength = llGetListLength(parts);
    
    if (partsLength == 1 ||
        llList2String(parts, 1) == "list" ||
        llList2String(parts, 1) == "show")
    {
        integer listIdx;
        integer listLength = llGetListLength(modifyList);
        string message;
        
        if (listLength == 0)
        {
            llInstantMessage(id, "List is empty.");
        }
        else
        {
            llInstantMessage(id, "Avatars: "
                + llList2CSV(modifyList));
        }
        
        return modifyList;
    }
    else if (llList2String(parts, 1) == "add")
    {
        if (partsLength <3)
        {
            llInstantMessage(id, "You must specify an avatar to add to the list.");
        }
        else
        {
            string target = llDumpList2String(llList2List(parts, 2, partsLength - 1), " ");
            
            llInstantMessage(id, "Adding \""
                + target + "\" to list.");
        
            return llListInsertList(modifyList, [target], 0);
        }
    }
    else if (llList2String(parts, 1) == "remove")
    {
        if (partsLength < 3)
        {
            llInstantMessage(id, "You must specify an avatar to remove from the list.");
        }
        else
        {
            integer targetIdx;
            string target = llDumpList2String(llList2List(parts, 2, partsLength - 1), " ");
            
            targetIdx = llListFindList(modifyList, [target]);
            if (targetIdx < 0)
            {
                llInstantMessage(id, "The avatar \""
                    + target + "\" is not in this list.");
            }
            else
            {
                llInstantMessage(id, "Removing \""
                    + target + "\" from list.");
                return llDeleteSubList(modifyList, targetIdx, targetIdx);
            }
        }
    }
    else
    {
        llInstantMessage(id, "Unrecognised command \""
            + llList2String(parts, 1) + "\"; expected \"show\", \"add\" or \"remove\".");
    }
    
    return modifyList;
}

integer validateListen(integer channel, string name, key id)
{
    key owner = llGetOwner();
        
    if (channel != g_ListenChannel)
    {
        return FALSE;
    }
        
    if (id != owner &&
        llGetOwnerKey(id) != owner &&
        // The llGetOwnerKey() is the only way I could find of checking
        // we're hearing an avatar.
        (llGetOwnerKey(id) != id ||
        llListFindList(g_Managers, [name]) >= 0))
    {
        return FALSE;
    }
    
    return TRUE;
}

// Attempts to read in the configuration, whitelist, blacklist and manager list,
// then proceeds to the closed state.
default
{
    changed(integer change)
    {
        if (change & CHANGED_INVENTORY)
        {
            if (!reloadConfiguration())
            {
                state ready;
            }
        }
    }

    dataserver(key queryID, string data)
    {
        if (queryID != g_NotecardQuery)
        {
            return;
        }
        
        if (data == EOF)
        {
            // Go back to the start of the notecard, because we're about to load
            // a new notecard.
            g_NotecardLine = 0;
            
            // And automatically proceed to the next configuration stage.
            g_ConfigurationStage++;
            
            // If we're at the end of a notecard, look for a further notecard to read, or
            // proceed to the door setup state if we've read all the notecards in.
            integer notecardCount = llGetListLength(CONFIGURATION_NOTECARDS);
    
            for (; g_ConfigurationStage , 1.0);
            if (g_SoundVolume > 0.0) {
                if (llGetInventoryType(g_ChimeSoundName) != INVENTORY_SOUND)
                {
                    g_ChimeSoundName = "";
                }
                if (llGetInventoryType(g_ClosingSoundName) != INVENTORY_SOUND)
                {
                    g_ClosingSoundName = "";
                }
                if (llGetInventoryType(g_LockedSoundName) != INVENTORY_SOUND)
                {
                    g_LockedSoundName = "";
                }
                if (llGetInventoryType(g_OpeningSoundName) != INVENTORY_SOUND)
                {
                    g_OpeningSoundName = "";
                }
                if (llGetInventoryType(g_UnlockedSoundName) != INVENTORY_SOUND)
                {
                    g_UnlockedSoundName = "";
                }
            }
        
            state ready;
        }
       
        if (g_ConfigurationStage == 0)
        {
            parseConfigurationLine(data);
        }
        else if (g_ConfigurationStage == 1)
        {
            g_Whitelist += data;
        }
        else if (g_ConfigurationStage == 2)
        {
            g_Blacklist += data;
        }
        else if (g_ConfigurationStage == 3)
        {
            g_Managers += data;
        }
        
        g_NotecardQuery = llGetNotecardLine(llList2String(CONFIGURATION_NOTECARDS, g_ConfigurationStage), g_NotecardLine++);
    }

    state_entry()
    {
        llSetText("Loading configuration...", <1 .0, 1.0, 1.0>, 1.0);
        if (!reloadConfiguration())
        {
            state ready;
        }
    }
    
    state_exit()
    {
        llSetText("", <1 .0, 1.0, 1.0>, 0.0);
        g_SwingVector = <0, 0, g_SwingDegrees * DEG_TO_RAD>;
    }
}

state ready
{
    changed(integer change)
    {
        if (change & CHANGED_INVENTORY)
        {
            state default;
        }
    }
    
    listen( integer channel, string name, key id, string message)
    {
        if (!validateListen(channel, name, id))
        {
            return;
        }
        
        message = llStringTrim(llToLower(message), STRING_TRIM);
        
        if (message == "lock")
        {
            // Cancel any auto-close.
            llSetTimerEvent(0.0);
            
            if (g_SoundVolume > 0.0 &&
                g_LockedSoundName != "")
            {
                llTriggerSound(g_LockedSoundName, g_SoundVolume);
            }
            llSay(0, "Locked");
            g_IsLocked = TRUE;
        }
        else if (message == "toggle")
        {
            state swinging;
        }
        else if (message == "unlock")
        {
            if (!g_IsClosed &&
                g_AutoClose > 0.0)
            {
                llSetTimerEvent(g_AutoClose);
            }
        
            if (g_SoundVolume > 0.0 &&
                g_UnlockedSoundName != "")
            {
                llTriggerSound(g_UnlockedSoundName, g_SoundVolume);
            }
            llSay(0, "Unlocked");
            g_IsLocked = FALSE;
        }
        else if (llSubStringIndex(message, "white") == 0)
        {
            g_Whitelist = updateList(id, g_Whitelist, message);
        }
        else if (llSubStringIndex(message, "black") == 0)
        {
            g_Blacklist = updateList(id, g_Blacklist, message);
        }
        else
        {
            llInstantMessage(id, "Unrecognised command \""
                + message + "\".");
        }
    }
    
    state_entry()
    {
        if (g_ListenChannel >= 0)
        {
            llListen(g_ListenChannel, "", NULL_KEY, "");
        }

        if (!g_IsClosed &&
            g_AutoClose > 0.0)
        {
            llSetTimerEvent(g_AutoClose);
        }
    }
    
    state_exit()
    {
        llSetTimerEvent(0.0);
    }
    
    timer()
    {
        state swinging;
    }
    
    touch_end(integer numTouching)
    {
        integer i;
        
        for (i = 0; i  0.0 &&
                g_OpeningSoundName != "")
            {
                llTriggerSound(g_OpeningSoundName, g_SoundVolume);
            }
        
            g_ClosedRot = llGetLocalRot();
            g_OpenRot = delta * g_ClosedRot ;
            g_UpAxis = llRot2Up(g_ClosedRot);
            
            llSetTimerEvent(g_SwingTime);
            llTargetOmega(g_UpAxis, g_SwingVector.z / g_SwingTime, 1.0);
        }
        else
        {
            if (g_SoundVolume > 0.0 &&
                g_ClosingSoundName != "")
            {
                llTriggerSound(g_ClosingSoundName, g_SoundVolume);
            }
            llSetTimerEvent(g_SwingTime);
            llTargetOmega(g_UpAxis, -(g_SwingVector.z / g_SwingTime), 1.0);
        }
    }
    
    state_exit()
    {
        llSetTimerEvent(0.0);
    }
    
    timer()
    {
        llTargetOmega(g_UpAxis, 0, 0);
        if (g_IsClosed)
        {
            llSetLocalRot(g_OpenRot);
        }
        else
        {
            llSetLocalRot(g_ClosedRot);
        }
        
        g_IsClosed = !g_IsClosed;
        
        state ready;
    }
}

 

Add a comment

HP Door

From Tony SkyBlinder Hirons:

Hello,

This script is for break one door, or can be used for other prims.

You can change the timer for reload the HP.

Can be one good tool for doing rp too.

If you have any questions let me know, ty.

//This script is distributed for free and must stay that way.

integer counter = 500;
float TIMER = 180.0;


conteur (){
counter -= 10;
llSetText((string)counter +"/500 HP", <1 .0, 1.0, 1.0>, 1.0);
if (counter <500)
{
TIMER = 180.0;//here we can change the timer
llSetTimerEvent(TIMER);
llSetColor(<0.20000, 0.90196, 0.80392>, ALL_SIDES );
} 
if (counter <1)
{
llMessageLinked(LINK_SET, 0, "dk", NULL_KEY);
llSetText("", <1.0, 0.0, 0.0>, 1.0);
llSetAlpha(0.0,ALL_SIDES);
llSetPrimitiveParams();
TIMER = 120.0;// here I change the timer
llSetTimerEvent(TIMER);
}
}


default
{
state_entry()
{ 
llMessageLinked(LINK_SET, 0, "dr", NULL_KEY);
llSetText((string)counter +"/500 HP", <1 .0, 0.0, 0.0>, 1.0); 
llSetColor(<0.20000, 0.90196, 0.80392>, ALL_SIDES );
}
collision(integer num)

{

if (llDetectedType(0) & AGENT)
{

llCollisionFilter("none", NULL_KEY, TRUE);
llSleep(0.1);
llCollisionFilter("", NULL_KEY, TRUE);
}
else {
conteur ();}
}

    
timer(){

llMessageLinked(LINK_SET, 0, "dr", NULL_KEY);
counter =500;
llSetAlpha(0.50,ALL_SIDES);
//llSetColor(<0.0, 0.0, 1.0>, ALL_SIDES );
llSetPrimitiveParams();
llSetText((string)counter +"/500 HP", <1 .0, 0.0, 0.0>, 1.0);
llSetTimerEvent(0.0);}
    }

 

Add a comment

Basic Smooth Sliding Door ( V1 )

Sliding door that glides smoothly from closed to open and back with an auto timer.

 

  • DO NOT LINK TO HOUSE (even though it is quite funny).
// V1 //
 
vector target = <1 .5, 0.1, 0.0>; // Play about to get the result you want.
// Each of the 3 floats represents X, Y, Z region axis in meters.
 
float time = 10.0; // Time for auto close. Set to zero to disable.
 
//////////////////////////////////////////////////////////////////
 
integer t;
 
integer open;
 
vector pos;
 
Door()
{
    vector targ;
    if(!open)
    {
        targ = (pos + target);
        llSetTimerEvent(time);
    }
    else
    {
        llSetTimerEvent(0.0);
        targ = (pos);
    }
    open = (!open);
    t = llTarget(targ, 0.04);
    llMoveToTarget(targ, 0.75);
    llSetStatus(STATUS_PHYSICS |
                STATUS_PHANTOM, TRUE);
}
 
default
{
    on_rez(integer param)
    {
        llResetScript();
    }
    state_entry()
    {
        llSetStatus(STATUS_BLOCK_GRAB, TRUE);
        llSetStatus(STATUS_PHYSICS |
                    STATUS_ROTATE_X |
                    STATUS_ROTATE_Y |
                    STATUS_ROTATE_Z |
                    STATUS_PHANTOM, FALSE);
        pos = llGetPos();
    }
    touch_start(integer nd)
    {
        Door();
    }
    at_target(integer num, vector tpos, vector opos)
    {
        llTargetRemove(t);
        llSetStatus(STATUS_PHYSICS |
                    STATUS_PHANTOM, FALSE);
        llSetPos(tpos);
    }
    timer()
    {
        llSetTimerEvent(0.0);
        Door();
    }
}

 

Add a comment

Shutter Door ( V2 )

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, ,
                                              PRIM_TEXTURE, 4, texture, , <(o -= (speed / 2)),0.0,0.0>, rot,
                                              PRIM_TEXTURE, 0, texture, , <(-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, ,
                                              PRIM_TEXTURE, 4, texture, , <(o += (speed / 2)),0.0,0.0>, rot,
                                              PRIM_TEXTURE, 0, texture, , <(-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));
    }
}

 

Add a comment

Very Simple Doors

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

 

 

Create'o'Door'o'Matic'o'Script ( V2 )

 

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

 

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

 

 

Rotating Door ( V3 )

 

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

 

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

 

 

Sliding Door ( V2 )

 

Very simple sliding type door with an auto close timer.

 

// V2 //
 
vector offset = <2 .0, 0.5, 0.0>; // Set how much in each direction (X,Y,Z) the prim moves...
// ...from it's closed position.
 
float time = 10.0; // The amount of time the door remain open before auto closing.
// Set to zero ( 0.0 ) to disable.
 
///////////////////////////////////////////////////////
 
vector door_open; // Used to store the open position.
 
vector door_closed; // Used to store the closed position.
 
integer open = TRUE; // Used to instruct the Door function.
 
Door(integer i) // The named function and its integer instruction.
{
    if(i) // If i is TRUE open the door.
    {
        llSetPos(door_open); // Set the local position to door_open.
        llSetTimerEvent(time); // Set the timer to running.
    }
    else // If i is FALSE close the door.
    {
        llSetTimerEvent(0.0); // Stop the timer.
        llSetPos(door_closed); // Set the local position to door_closed.
    }
    open = (!i); // Set the value of open to NOT the value of the instruction so...
}                // ...next time it is called it does the opposite.
 
default // Create a state for the code to run in.
{
    on_rez(integer param) // Triggered when the door (linked or not) is rezzed.
    {
        llResetScript(); // Clear the script memory and start fresh.
    }
    changed(integer change) // Triggered when the prim senses various changes.
    { // BEWARE: This is a simple script and will not discern if the door is being sat on.
      // THE SCRIPT WILL RESET IF THE DOOR IS SAT ON.
        if(change & CHANGED_LINK) // Check if the change was in how the prim is linked.
        llResetScript(); // Reset the script to reset the positions.
    }
    state_entry() // Triggered on entering the state.
    {
        door_closed = llGetLocalPos(); // Store the local position of the closed door.
        // The closed door is the position the script measures of the prim when...
        // the script is first run in it.
        door_open = (door_closed + offset);
        // Store the position for the open door by adding the desired offset.
    }
    touch_start(integer nd) // Triggered when the door is touched.
    {
        Door(open); // Instruct the Door function to either open or close...
    }               // ...depending on the value of "open".
    timer() // Triggered when a timer is set and the specified time has elapsed.
    {
        Door(FALSE); // Close the door.
    }
}

 

Add a comment