door script

Creating scripts
Post Reply
User avatar
Constance Peregrine
Posts: 2349
Joined: Sun Dec 23, 2012 11:35 am
Has thanked: 2778 times
Been thanked: 1482 times

door script

Post by Constance Peregrine »

this is kinda interesting...

Code: Select all

// deluxe door script by Ezhar Fairlight
// features: one prim, no building skills required, automatic closing, workaround for rotation drift,
// doesn't mess up when moved, adjustable direction (inwards/outwards) and sound volume, HHGG quotes!
// updated for SL 1.5

// just rez a cube primitive and put this script inside - it will shape and texture itself into a door

// ********** SETTINGS HERE ************
float       TIMER       = 30.0;      // automatically close the door after this many seconds,
                                    // set to 0 to disable automatic closing

integer     DIRECTION   = 1;       // direction door opens in. Either 1 (outwards) or -1 (inwards);

float       VOLUME      = 0.8;      // sound volume, 1.0 loudest, 0.0 to disable sound
// ********** END OF SETTINGS **********


key         SOUND_OPEN  = "cb340647-9680-dd5e-49c0-86edfa01b3ac";
key         SOUND_CLOSE = "e7ff1054-003d-d134-66be-207573f2b535";

vector      gPos;      // door position (objects move a tiny amount
                        // away from their position each time they are rotated,
                        // thus we need to workaround this by resetting
                        // the position after rotating)
                       
door(integer open) {
    if (open) {
        llTriggerSound(SOUND_OPEN, VOLUME);
        llSetRot(llEuler2Rot(<0, 0, -DIRECTION * PI_BY_TWO>) * llGetRot());
    } else { // close
        llSetRot(llEuler2Rot(<0, 0, DIRECTION * PI_BY_TWO>) * llGetRot());
        llTriggerSound(SOUND_CLOSE, VOLUME);
    }
}
       

default {   // first time startup
    state_entry() {
        if (llGetTexture(0) == "89556747-24cb-43ed-920b-47caed15465f") { // is default texture, set it up
            llSetPos(llGetPos() + <0, 0, 3.325 / 2 - 0.25>);
            llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, PRIM_HOLE_DEFAULT, <0.375, 0.875, 0>, 0.0, ZERO_VECTOR, <1, 1, 0>, ZERO_VECTOR,
                PRIM_SIZE, <0.2, 4, 3.325>,
                PRIM_TEXTURE, 0, "086c7e6b-bdd6-7388-f146-f3d1b353ed15", <2.000000, 0.060000, 0.000000>, <0.500015, 0.469985, 0.000000>, 1.570840,
                PRIM_TEXTURE, 1, "086c7e6b-bdd6-7388-f146-f3d1b353ed15", <-2.000000, 1.000000, 0.000000>, <0.500015, 0.000000, 0.000000>, 0.000000,
                PRIM_TEXTURE, 2, "086c7e6b-bdd6-7388-f146-f3d1b353ed15", <0.100000, 1.000000, 0.000000>, <0.599994, 0.000000, 0.000000>, 0.000000,
                PRIM_TEXTURE, 3, "086c7e6b-bdd6-7388-f146-f3d1b353ed15", <2.000000, 1.000000, 0.000000>, <0.500015, 0.000000, 0.000000>, 0.000000,
                PRIM_TEXTURE, 4, "086c7e6b-bdd6-7388-f146-f3d1b353ed15", <2.000000, 0.080000, 0.000000>, <0.500015, 0.550005, 0.000000>, 1.570840,
                PRIM_TEXTURE, 5, "086c7e6b-bdd6-7388-f146-f3d1b353ed15", <0.100000, 1.000000, 0.000000>, <0.449995, 0.000000, 0.000000>, 0.000000,
                PRIM_TEXTURE, 6, "086c7e6b-bdd6-7388-f146-f3d1b353ed15", <0.100000, 1.000000, 0.000000>, <0.449995, 0.000000, 0.000000>, 0.000000]
            );
            llSetObjectName("Door");
        }
        gPos = llGetPos();  // remember where we're supposed to be
        door(TRUE);
        state closed;
    }
}
   
state closed {  // door is closed
    on_rez(integer start_param) {
        gPos = llGetPos();
    }

    state_entry() {
        door(FALSE);
    }

    touch_start(integer total_number) {
        state open;
    }

    moving_end() {  // done moving me around, store new position
        gPos = llGetPos();
    }
}

state open {    // door is open
    on_rez(integer start_param) {
        gPos = llGetPos();
        state closed;
    }

    state_entry() {
        llSetTimerEvent(TIMER);
        llSetPos(gPos); // rotation drift workaround
        door(TRUE);
    }
   
    touch_start(integer num) {
        state closed;
    }
   
    timer() { // auto-close
        state closed;
    }
   
    moving_start() { // close when being moved
        state closed;
    }
   
    state_exit() {
        llSetTimerEvent(0);
    }
}
These users thanked the author Constance Peregrine for the post:
Dundridge Dreadlow
Laissez faire et laissez passer, le monde va de lui même!
My little sounds store https://www.kitely.com/market?store=2040306

Ephemeral wanderer...
User avatar
Dundridge Dreadlow
Posts: 616
Joined: Mon May 06, 2013 2:23 pm
Location: England
Has thanked: 590 times
Been thanked: 339 times

Re: door script

Post by Dundridge Dreadlow »

hey, the textures and sounds work too ! 8-)
These users thanked the author Dundridge Dreadlow for the post:
Sierra Jakob
ImageImageImageImageImageImage
PS. Kitely is awesome.
User avatar
Constance Peregrine
Posts: 2349
Joined: Sun Dec 23, 2012 11:35 am
Has thanked: 2778 times
Been thanked: 1482 times

Re: door script

Post by Constance Peregrine »

Dundridge Dreadlow wrote:hey, the textures and sounds work too ! 8-)

hehe-))
Laissez faire et laissez passer, le monde va de lui même!
My little sounds store https://www.kitely.com/market?store=2040306

Ephemeral wanderer...
JIM SMART
Posts: 2
Joined: Wed Dec 18, 2013 4:19 pm
Has thanked: 0
Been thanked: 0

Re: door script

Post by JIM SMART »

Does anyone have a script for synchronized opening & closing a set of double doors? I brought over one script Fro Inworldz, but it would not work in Kitely. Any information would sure be appreciated. Thanks :) :) :)
User avatar
Constance Peregrine
Posts: 2349
Joined: Sun Dec 23, 2012 11:35 am
Has thanked: 2778 times
Been thanked: 1482 times

Re: door script

Post by Constance Peregrine »

Hey Jim,

I have not tried these in Kitely but they should work in any OS grid.

inwz has it's own scripting in many regards, so many times scripts that work there will not work in grids running current OS.

I would love to know if they work.

Code: Select all

// Smooth Door Script - Version 1.1
// by Toy Wylie
// swing on z axis changes by Clarke Kondor
// Distributed under the following licence:
// - You can use it in your own works
// - You can sell it with your work
// - This script must remain full permissions
// - This header notice must remain intact
// - You may modify this script as needed
 
float openingTime=2.0;      // in seconds
float openingAngle=-90.0;    // in degrees
float autocloseTime=5.0;    // in seconds
integer steps=4;            // number of internal rotation steps
integer useOmega=TRUE; 
float omega=0.0;
 
vector axis;
rotation closedRot;
rotation openRot;
 
integer swinging;
integer open;
 
openDoor(integer yes)
{
    vector useAxis=axis;
    open=yes;
 
    if(!yes)
        useAxis=-axis;
 
    llSetTimerEvent(openingTime/(float) steps);
    if (useOmega) llTargetOmega(useAxis,omega,1.0);
}
 
go()
{
    if(swinging==0)
    {
        if(!open)
        {
            axis=llRot2Up(llGetLocalRot());
            closedRot=llGetLocalRot();
            openRot=llEuler2Rot(<0.0,0.0,openingAngle>*DEG_TO_RAD)*closedRot;
        }
        swinging=steps;
        openDoor(!open);
    }
}
 
rotation  slerp(rotation source,rotation target,float amount)
{
    float startAngle = llRot2Angle(source);
    float endAngle = llRot2Angle(target);
    
    //llOwnerSay((string)startAngle+ " " + (string)(startAngle*RAD_TO_DEG));
    //llOwnerSay((string)(endAngle*RAD_TO_DEG));
   // llOwnerSay(llRot2Axis(source*target));
    float thisAngle = (endAngle-startAngle) * amount + startAngle;
    //llOwnerSay((string)(thisAngle*RAD_TO_DEG));
    //if (thisAngle > PI) thisAngle -= TWO_PI;
    //llOwnerSay((string)(thisAngle*RAD_TO_DEG));
    
    rotation newRot;
    newRot = llAxisAngle2Rot(llRot2Axis(source*target),thisAngle);
    //newRot = llAxisAngle2Rot(<0.0,0.0,1.0>,thisAngle);
    //newRot = llAxisAngle2Rot(xaxis,thisAngle);
    return newRot;
}
 
default
{
    state_entry()
    {
        swinging=0;
        open=FALSE;
        omega=DEG_TO_RAD*openingAngle/openingTime;
        //omega=TWO_PI/360*openingAngle/openingTime;
        if (useOmega) llTargetOmega(ZERO_VECTOR,1.0,1.0);
    }
 
    touch_start(integer dummy)
    {
        go();
    }
 
    collision_start(integer dummy)
    {
        go();
    }
 
    timer()
    {
        if(swinging>0)
        {
            swinging--;
            if(swinging!=0)
            {
                float amount=(float) swinging/(float) steps;
                if(open)
                    amount=1.0-amount;
                llSetLocalRot(slerp(closedRot,openRot,amount));
                return;
            }
 
            if (useOmega) llTargetOmega(axis,0.0,0.0);
            if(open)
            {
                llSetLocalRot(openRot);
                llSetTimerEvent(autocloseTime);
            }
            else
            {
                llSetLocalRot(closedRot);
                llSetTimerEvent(0.0);
            }
        }
        else // autoclose time reached
        {
            llSetTimerEvent(0.0);
            openDoor(!open);
            swinging=steps;
        }
    }
}

Code: Select all

// 610 Swinging Door
// Sixten Inferno
// 1.00 - 12/4/08 - First Created
// 1.01 - 1/23/09 - Added Autoclose and some general clean up - Renamed from 610 Smooth Door

// This can be used in a free standing or linkset as long as the door is not the root prim.
// If this script is in the root prim of a linked set then the whole set will rotate with the root prim
// This can be useful for example a coffin lid.
// This can be used with a standard prim, cut prim, and sliced prim.

// Axis to rotate on, x, y, or z
string axis = "y";

// Set Synced Sounds
string soundOpen = "";
string soundClose = "2fe283ca-35ab-4b1d-aaec-78d50c705cd1";
string soundMoving = "2fe283ca-35ab-4b1d-aaec-78d50c705cd1";

// Access Variables
integer isLocked = FALSE;
// Add Full names of avatars to list below if you want them to have access when door is locked
// example = ["Sixten Inferno", "Alice WunderKinde"]
list accessAllowAvatar = [];

// Auto Close 
integer autoCloseOn = TRUE;

// Turn on or off DebugMode
integer debugModeOn = FALSE;

//
// dont change anything below this line unless you know what you are doing.
//

rotation angleRotation;
float spinDirection;
integer angleDegrees = 90;
key toucherKey;
string ScriptName;

Debug(string output)
{
    if(debugModeOn)
    {
        llOwnerSay(ScriptName +  ": " + output);
    }
}

ToggleDoor()
{
    rotation rot = llGetRot();
    llLoopSound(soundMoving, 1.0);
    
    if(axis == "y")
    {
        angleRotation = llEuler2Rot(<(float)angleDegrees, 0.0, 0.0> * DEG_TO_RAD);
        llTargetOmega(<spinDirection, 0.0, 0.0> * rot, 0.5, 1.0);
    }
    if(axis == "z")
    {
        angleRotation = llEuler2Rot(<0.0, (float)angleDegrees, 0.0> * DEG_TO_RAD);
        llTargetOmega(<0.0, spinDirection, 0.0> * rot, 0.5, 1.0);
    }
    if(axis == "x")
    {
        angleRotation = llEuler2Rot(<0.0, 0.0, (float)angleDegrees> * DEG_TO_RAD);
        llTargetOmega(<0.0, 0.0, spinDirection> * rot, 0.5, 1.0);
    }
    
    llSleep(3.0); 
    llTargetOmega( <0.,0.,0.>, 0.0, 0.0 );
    llStopSound();
    
    angleRotation.s *= spinDirection;
    llSetLocalRot(angleRotation * llGetLocalRot());
}

integer PermissionCheck(key id)
{
    integer hasPermission = FALSE;
    
    if(isLocked == FALSE)
    {
        hasPermission = TRUE;
    }
    else if(llGetOwnerKey(id) == llGetOwner())
    {
        hasPermission = TRUE;
    }
    else if(llGetKey() == id)
    {
        hasPermission = TRUE;
    }
    else
    {
        integer inList = llListFindList(accessAllowAvatar, [llKey2Name(id)]);
        
        if(inList != -1)
        {
            hasPermission = TRUE;
        }
    }
    
    return hasPermission;
}

default
{
    state_entry()
    {
        ScriptName = llGetScriptName();
        state Closed;
    }
}

state Open
{
    state_entry()
    {
        spinDirection = 1;
        
        if(autoCloseOn == TRUE)
        {
            llSetTimerEvent(10.0);
        } 
    }
    
    touch_start(integer count)
    {
        toucherKey = llDetectedKey(0);
        
        if(PermissionCheck(toucherKey))
        {
            state Closing;
        }
    }
    
    timer()
    {
        state Closing;
    }
}

state Opening
{
    state_entry()
    {
        llPlaySound(soundOpen, 1.0);
        ToggleDoor();
        state Open;
    }
}

state Closed
{
    state_entry()
    {
        spinDirection = -1;   
    }
    
    touch_start(integer count)
    {
        toucherKey = llDetectedKey(0);
        
        if(PermissionCheck(toucherKey))
        {
            state Opening;
        }
    }
}

state Closing
{
    state_entry()
    {
        llSetTimerEvent(0.0);
        ToggleDoor();
        llPlaySound(soundClose, 1.0);
        state Closed;
    }
}

Code: Select all

//------------------------------------------------------
// Timeless Linked Door Script by Timeless Prototype
//------------------------------------------------------
// The latest version of this script can always be found
// in the Library section of the wiki:
// http://www.secondlife.com/badgeo/
// This script is free to use, but whereever it is used
// the SCRIPT's permissions MUST be set to:
// [x] Next owner can modify
// [x] Next owner can copy
// [x] Next owner can transfer
// [x] Allow anyone to copy
// [x] Share with group

//------------------------------------------------------
// USAGE INSTRUCTIONS FOR EVERYDAY USE:
//------------------------------------------------------
// Say the following commands on channel 0:
// 'unlock'     - Unlocks all doors in range.
// 'lock'       - Locks all doors in range and allows
//                only the permitted users to open it.
// To open the door, either Touch it, Walk into it or
// say 'open' or say 'close'.

//------------------------------------------------------
// USAGE INSTRUCTIONS FOR BUILDERS:
//------------------------------------------------------
// 1. Copy and paste this script into the door prim and
//    change the settings (see further down).
// 2. The door prim must be linked to at least one other
//    prim (could be linked to the house for example).
// 3. The door prim MUST NOT be the root prim.
// 4. Use Edit Linked Parts to move, rotate and size the
//    door prim for the closed state.
// 5. When ready, stand close to the door and say
//    '/door closed' (this records the closed door
//    position, rotation and size to the object's
//    name and description).
// 6. Use the Edit Linked parts to move, rotate and size
//    the door prim for the opened state.
// 7. When ready, stand close to the door and say
//    '/door opened' (this records the opened door
//    position, rotation and size).
// 8. Once recorded it will not accept these commands
//    again. If you do need to redo the settings then
//    delete the Name and Description of the door prim
//    (these are where the position information is
//    stored), and then follow the steps above again.
//    Note: deleting the object name won't save, so set
//    the object name to 'Object' to reset the object
//    name.

//------------------------------------------------------
// Change these settings to suit your needs.
//------------------------------------------------------
// To mute any/all of the sounds set the sound string(s)
// to "" (empty string).
// To get the UUID of a sound, right click on the sound
// in your inventory and choose "Copy Asset UUID", then
// paste the UUID in here.
string      doorOpenSound       = "4b58bf37-fb8a-4648-9d19-cd9da76c3213";
string      doorCloseSound      = "a29ec487-72cc-4124-a703-3bfb6bc0ab26";
string      confirmedSound      = "";
string      accessDeniedSound   = "";
string      doorBellSound       = ""; // Setting to empty stops door announcements too.
float       autoCloseTime       = 120.0; // 0 seconds to disable auto close.
integer     allowGroupToo       = TRUE; // Set to FALSE to disallow same group access to door.
list        allowedAgentUUIDs   = ["8efecbac-35de-4f40-89c1-2c772b83cafa"]; // Comma-separated, quoted list of avatar UUIDs who are allowed access to this door.
integer     listenChannel       = 0;


//------------------------------------------------------
// Leave the rest of the settings alone, these are
// handled by the script itself.
//------------------------------------------------------
integer     isLocked              = FALSE; // Only when the door is locked do the permissions apply.
integer     isOpen              = TRUE;
vector      openPos             = ZERO_VECTOR;
rotation    openRot             = ZERO_ROTATION;
vector      openScale           = ZERO_VECTOR;
vector      closedPos           = ZERO_VECTOR;
rotation    closedRot           = ZERO_ROTATION;
vector      closedScale         = ZERO_VECTOR;
key         openerKey           = NULL_KEY;
key         closerKey           = NULL_KEY;
integer     isSetup             = FALSE;
integer     listenHandle        = 0;
string      avatarName          = "";

mySayName(integer channel, string objectName, string message)
{
    string name = llGetObjectName();
    llSetObjectName(objectName);
    llSay(0, "/me " + message);
    llSetObjectName(name);
}

mySay(integer channel, string message)
{
    string name = llGetObjectName();
    llSetObjectName("Door");
    llSay(0, message);
    llSetObjectName(name);
}

myOwnerSay(string message)
{
    string name = llGetObjectName();
    llSetObjectName("Door");
    llOwnerSay(message);
    llSetObjectName(name);
}

mySoundConfirmed()
{
    if (confirmedSound != "")
    {
        llTriggerSound(confirmedSound, 1.0);
    }
}

mySoundAccessDenied()
{
    if (accessDeniedSound != "")
    {
        llTriggerSound(accessDeniedSound, 1.0);
    }
}

myGetDoorParams()
{
    isSetup = FALSE;
    if (llSubStringIndex(llGetObjectDesc(), "door;") == 0 && llSubStringIndex(llGetObjectName(), "door;") == 0)
    {
        list nameWords = llParseString2List(llGetObjectName(), [";"], []);
        list descWords = llParseString2List(llGetObjectDesc(), [";"], []);
        if (llGetListLength(nameWords) != 4 || llGetListLength(descWords) != 4)
        {
            myOwnerSay("The door prim's name and/or description has invalid syntax and/or number of parameters. Delete the door prim's name and description and setup the door prim again.");
        }
        else
        {
            openPos = (vector)llList2String(nameWords, 1);
            openRot = (rotation)llList2String(nameWords, 2);
            openScale = (vector)llList2String(nameWords, 3);
            closedPos = (vector)llList2String(descWords, 1);
            closedRot = (rotation)llList2String(descWords, 2);
            closedScale = (vector)llList2String(descWords, 3);
            isSetup = TRUE;
        }
    }
}

mySetDoorParams(vector openPos, rotation openRot, vector openScale, vector closedPos, rotation closedRot, vector closedScale)
{
    llSetObjectName("door;" +
        (string)openPos + ";" +
        (string)openRot + ";" +
        (string)openScale);
    llSetObjectDesc("door;" +
        (string)closedPos + ";" +
        (string)closedRot + ";" +
        (string)closedScale);
    isSetup = TRUE;
}

integer myPermissionCheck(key id)
{
    integer hasPermission = FALSE;
    if (isLocked == FALSE)
    {
        hasPermission = TRUE;
    }
    else if (llGetOwnerKey(id) == llGetOwner())
    {
        hasPermission = TRUE;
    }
    else if (allowGroupToo == TRUE && llSameGroup(id))
    {
        hasPermission = TRUE;
    }
    else if (llListFindList(allowedAgentUUIDs, [(string)id]) != -1)
    {
        hasPermission = TRUE;
    }
    return hasPermission;
}

myOpenDoor()
{
    isOpen = FALSE;
    myToggleDoor();
}

myCloseDoor()
{
    isOpen = TRUE;
    myToggleDoor();
}

myToggleDoor()
{
    if (isSetup == FALSE)
    {
        myOwnerSay("The door prim has not been configured yet. Please read the usage instructions in the door script.");
    }
    else if (llGetLinkNumber() == 0 || llGetLinkNumber() == 1)
    {
        myOwnerSay("The door prim must be linked to at least one other prim and the door prim must not be the root prim");
    }
    else
    {
        isOpen = !isOpen;
        if (isOpen)
        {
            if (doorBellSound != "")
            {
                llTriggerSound(doorBellSound, 1.0);
                if (avatarName != "")
                {
                    mySayName(0, avatarName, "is at the door.");
                    avatarName = "";
                }
            }
            if (doorOpenSound != "")
            {
                llTriggerSound(doorOpenSound, 1.0);
            }
            llSetPrimitiveParams([ PRIM_POSITION, openPos, PRIM_ROTATION, ZERO_ROTATION * openRot / llGetRootRotation(), PRIM_SIZE, openScale ]);
            // Door API.
            llMessageLinked(LINK_SET, 255, "cmd|door|opened", NULL_KEY);
        }
        else
        {
            if (doorCloseSound != "")
            {
                llTriggerSound(doorCloseSound, 1.0);
            }
            llSetPrimitiveParams([ PRIM_POSITION, closedPos, PRIM_ROTATION, ZERO_ROTATION * closedRot / llGetRootRotation(), PRIM_SIZE, closedScale ]);
            // Door API.
            llMessageLinked(LINK_SET, 255, "cmd|door|closed", NULL_KEY);
        }
       
        llSetTimerEvent(0.0);
        if (isOpen == TRUE && autoCloseTime != 0.0)
        {
            llSetTimerEvent(autoCloseTime);
        }
    }
}

default
{
    state_entry()
    {
        listenHandle = llListen(listenChannel, "", NULL_KEY, "");
        myGetDoorParams();
    }

    touch_start(integer total_number)
    {
        if (myPermissionCheck(llDetectedKey(0)) == TRUE)
        {
            avatarName = llDetectedName(0);
            myToggleDoor();
        }
        else
        {
            mySoundAccessDenied();
        }
    }
   
    timer()
    {
        myCloseDoor();
    }
   
    link_message(integer sender_num, integer num, string str, key id)
    {
        // Door API. The API is here in case you want to create PIN entry keypads or whatever.
        if (num == llGetLinkNumber())
        {
            if (str == "cmd|door|doOpen")
            {
                myOpenDoor();
            }
            else if (str == "cmd|door|doClose")
            {
                myCloseDoor();
            }
        }
        if (str == "cmd|door|discover")
        {
            llMessageLinked(LINK_SET, 255, "cmd|door|discovered|" + (string)llGetKey(), id);
        }
    }
   
    listen(integer channel, string name, key id, string message)
    {
        // Performance note: it's quicker to compare the strings than to compare permissions each time anyone says anything on this channel.
        if (message == "open")
        {
            if (myPermissionCheck(id) == TRUE)
            {
                // Only open the door if the person is quite close to this door.
                openerKey = id;
                closerKey = NULL_KEY;
                avatarName = name;
                llSensor(name, id, AGENT, 5.0, TWO_PI);
            }
            else
            {
                mySoundAccessDenied();
            }
        }
        else if (message == "close")
        {
            if (myPermissionCheck(id) == TRUE)
            {
                openerKey = NULL_KEY;
                closerKey = id;
                avatarName = name;
                // Only close the door if the person is quite close to this door.
                llSensor(name, id, AGENT, 5.0, TWO_PI);
            }
            else
            {
                mySoundAccessDenied();
            }
        }
        else if (message == "lock")
        {
            if (myPermissionCheck(id) == TRUE)
            {
                isLocked = TRUE;
                mySoundConfirmed();
            }
            else
            {
                mySoundAccessDenied();
            }
        }
        else if (message == "unlock")
        {
            if (myPermissionCheck(id) == TRUE)
            {
                isLocked = FALSE;
                mySoundConfirmed();
            }
            else
            {
                mySoundAccessDenied();
            }
        }
        else if (message == "/door opened" && llSubStringIndex(llGetObjectName(), "door;") == -1)
        {
            if (llGetOwnerKey(id) == llGetOwner())
            {
                mySoundConfirmed();
                openPos = llGetLocalPos();
                openRot = llGetLocalRot();
                openScale = llGetScale();
                isOpen = TRUE;
                if (! (closedPos == ZERO_VECTOR && closedRot == ZERO_ROTATION && closedScale == ZERO_VECTOR))
                {
                    mySetDoorParams(openPos, openRot, openScale, closedPos, closedRot, closedScale);
                }
            }
            else
            {
                mySoundAccessDenied();
            }
        }
        else if (message == "/door closed" && llSubStringIndex(llGetObjectDesc(), "door;") == -1)
        {
            if (llGetOwnerKey(id) == llGetOwner())
            {
                mySoundConfirmed();
                closedPos = llGetLocalPos();
                closedRot = llGetLocalRot();
                closedScale = llGetScale();
                isOpen = FALSE;
                if (! (openPos == ZERO_VECTOR && openRot == ZERO_ROTATION && openScale == ZERO_VECTOR))
                {
                    mySetDoorParams(openPos, openRot, openScale, closedPos, closedRot, closedScale);
                }
            }
            else
            {
                mySoundAccessDenied();
            }
        }
    }
   
    sensor(integer num_detected)
    {
        if (openerKey != NULL_KEY)
        {
            integer i;
            for (i = 0; i < num_detected; i++)
            {
                if (llDetectedKey(i) == openerKey && myPermissionCheck(llDetectedKey(i)) == TRUE)
                {
                    myOpenDoor();
                }
            }
            openerKey = NULL_KEY;
        }
        else
        {
            integer i;
            for (i = 0; i < num_detected; i++)
            {
                if (llDetectedKey(i) == closerKey && myPermissionCheck(llDetectedKey(i)) == TRUE)
                {
                    myCloseDoor();
                }
            }
            closerKey = NULL_KEY;
        }
    }

//------------------------------------------------------
// Uncomment the following code if you particularly want
// collisions to affect the door state.   
//------------------------------------------------------

//    collision_start(integer num_detected)
//    {
//        integer i;
//        for (i = 0; i < num_detected; i++)
//        {
//            if (myPermissionCheck(llDetectedKey(i)) == TRUE)
//            {
//                avatarName = llDetectedName(i);
//                myOpenDoor();
//            }
//            else if (llDetectedType(i) & AGENT)
//            {
//                mySoundAccessDenied();
//            }
//        }
//    }

} // End of default state and end of script
Laissez faire et laissez passer, le monde va de lui même!
My little sounds store https://www.kitely.com/market?store=2040306

Ephemeral wanderer...
JIM SMART
Posts: 2
Joined: Wed Dec 18, 2013 4:19 pm
Has thanked: 0
Been thanked: 0

Re: door script

Post by JIM SMART »

Thanks for your response on my query. I have been quite busy lately and have not had a chance to try them. I think possibly the Timeless script might be what I am looking for. Again, thanks so much and will advise you of the outcomes on these scripts.
User avatar
Constance Peregrine
Posts: 2349
Joined: Sun Dec 23, 2012 11:35 am
Has thanked: 2778 times
Been thanked: 1482 times

Re: door script

Post by Constance Peregrine »

I hope any of them help-))
Laissez faire et laissez passer, le monde va de lui même!
My little sounds store https://www.kitely.com/market?store=2040306

Ephemeral wanderer...
User avatar
Handy Low
Posts: 231
Joined: Fri Nov 08, 2013 3:38 pm
Location: Yorkshire, England
Has thanked: 207 times
Been thanked: 140 times
Contact:

Re: door script

Post by Handy Low »

Shameless plug time ...

My door system will synchronise multiple doors, among other things: Handy's door & drawer system.
These users thanked the author Handy Low for the post (total 2):
Barnard SmithConstance Peregrine
Handy Low
User avatar
Barnard Smith
Posts: 70
Joined: Mon Jan 07, 2013 8:11 pm
Has thanked: 57 times
Been thanked: 28 times

Re: door script

Post by Barnard Smith »

Hi Handy,

And I can say from experience, I have all his tools and use them, they all work well either in SL or here in Kitely. His Tools are amazing!!
These users thanked the author Barnard Smith for the post (total 2):
Handy LowConstance Peregrine
User avatar
Handy Low
Posts: 231
Joined: Fri Nov 08, 2013 3:38 pm
Location: Yorkshire, England
Has thanked: 207 times
Been thanked: 140 times
Contact:

Re: door script

Post by Handy Low »

Thanks, Barnard. :)
Handy Low
Post Reply