A B C D E F G I J K L M N O R S T U V W
Ke Ki

This is a well-written sliding door script.  Written by Pavl Duke of SL.  Works in both SL and Opensim.

//  FREE SCRIPTS - TESTED AND WORKING ON KITELY

//  If you paid for this script, you were ripped off.
//  You may use in your creations.
//  You may not sell it as a script or in a script collection.

// Copy and paste the contents of this notecard into a new script.



//By all means make any and all uses you want to of this script, just don't sell it as a script, change the name or remove this or any other of the comments.

//This Script was written in a very basic form by Pavl Duke who then made the mistake of passing a copy to Robin Kierstrider who got all "nerr nerr nerr why doesnt it do more?" so now it does - Be warned!!


float time = 5;         //How long in seconds should the prim take to move..
float move = -3.0;      //How Far to move (this can be a negative number if the door is going the wrong way)
vector axis = <0,1,0>;  //Mark the x y or z axis with a 1 depending on which direction you need
float wait = 0.0;       //how long to stay open before closing - set to 0 for no auto-close
integer switch;
vector home;
vector moved;
do_it(vector here, vector target)
{
    float i;
    vector pos;
    vector mov = here - target;
    llResetTime();
    do
    {
        i = llGetTime()/time;
        pos =  (here - (mov*i));
        llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_POS_LOCAL,pos]);
        llSleep(time/40);//divide by a smaller number if it's causing lag
    }
    while (llGetTime() < time);
    llSetLinkPrimitiveParams(LINK_THIS,[PRIM_POS_LOCAL,(target)]);
}



default
{
    state_entry()
    {
        home = llList2Vector(llGetLinkPrimitiveParams(LINK_THIS,[PRIM_POS_LOCAL]),0);
    }

    touch_start(integer total_number)
    {
        if (axis.x > axis.y & axis.x > axis.z) moved = <move,0.0,0.0>;
        else if (axis.y > axis.z) moved = <0.0,move,0.0>;
        else moved = <0.0,0.0,move>;
        if (wait != 0)
        {
            do_it(home,home + moved);
            llSleep(wait);
            do_it(moved+home,home);
        }
        else if (!switch) do_it(home,home + moved);
        else do_it(moved+home,home);
        switch = !switch;
    }
}
//2012 Pavl Duke