Jump to content

Sliding Door Script


Britt32 Beck
 Share

You are about to reply to a thread that has been inactive for 274 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello, I have a cabinet that has two sliding doors, each needs to slide inwards towards the center of the cabinet. I can't find a script where i can set the distance needed to slide, everything i've bought so far slides too far and is not adjustable. I've found one that seems to work, but it's not a linkable script. Would anyone know of a script that is fully modifiable and has click to open, click to close? Thanks!

Link to comment
Share on other sites

A second independent door?  Just name the second door something else.  Notice the comment line in the script that says

// All prims in the door must be named "DOOR", and none can be the root prim of the linkset

Well, in your second door, name all prims something like "door" instead of "DOOR", and be sure to change the two places in the script that look for the name of the door that you touched.

  • Like 1
Link to comment
Share on other sites

Yes, I agree.  If you were a scripter, you could do just that.  This particular script is a very simple, bare bones script that could be modified in lots of ways, including managing several doors.  So, you have a choice.  You could either figure out how to change it yourself -- not a terribly difficult job -- or you could hire a scripter to do it for you.  Or, you could just go ahead and use two separate copies of this script, one in each door.  Frankly, the small inefficiency of using two scripts is almost negligible, and that's by far the easiest option you have.  If you were scripting an entire house full of doors, I'd think abut the modification.

Link to comment
Share on other sites

I needed a sliding door script (first time in over a decade if I am remembering correctly) for a pocket door for Lani's new trailer. I tried a bunch of sliding door scripts that I had saved including Rolig's ancient one but  this one the only one that I could make work. So it may be helpful. The slide is dependent on the direction you door needs to move so the default is East and West (if I am not too tired) and you would change for North to South. So that might not be what you are looking for, but here it is (no creator info on the file):

 

integer isOpen = FALSE;
vector originalPos;
float slideBy = 1.6;
init()
{
    originalPos = llGetLocalPos();
    vector size = llGetScale();
    // Set up the amount to move by. Use size.y instead of size.x
    // if you want to slide along the y-axis.
    slideBy = size.x - 0.22;
}
openclose()
{
  if (isOpen)
  {
    llSetPos(originalPos);
    isOpen = FALSE;
  }
  else
  {
    llSetPos(<originalPos.x + slideBy, originalPos.y, originalPos.z>);
    // To move alon the y-axis, use this instead:
    // llSetPos();
    isOpen = TRUE;
  }
}
default
{
    state_entry()
    {
        init();
    }
    on_rez(integer param)
    {
        init();
    }
    touch_start(integer total_number)
    {
        openclose();
    }
    changed(integer change)
    {
        // When the links change, reset the script
        // so that we pick up the changes.
        if (change & CHANGED_LINK)
        {
            llResetScript();
        }
    }
}

Link to comment
Share on other sites

Thank you both. Chic, I will try the script you have here so I can compare. As of now, the cabinet is working and by a bit of trial and error, I was also able to figure out how to modify a z axis swinging door to swing on the x, and move the pivot point from center to the far edge so it doesn't swing from the middle of the mesh. (this particular cabinet has a top hatch as well as the two sliding doors, that was problem 2, but now solved also!)

 

Thanks again. 

Edited by Britt32 Beck
  • Like 1
Link to comment
Share on other sites

And you said that you weren't a scripter!  This is how we all begin. A small challenge pokes us into trying something, and it works.  I should warn you ... once the bug bites, there's no turning back.  Scripting is like doing crossword puzzles or whatever your favorite puzzle is.  It's addictive, and very rewarding.  Keep at it. As you get stuck on whatever you are working on, feel free to bring it here to share.  This forum is a place for scripters to share insights and to commiserate about things that aren't quite working right yet.

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Hi all,

 

Britt32 BeckChic Aeon, Sorry to reassemble this topic, but I am unable to modify the sliding axis of my bay window. In my house, all the doors are oriented in the same direction, except one, which is in another axis. when i link my door to my building it doesn't want to open the right way, i tried to adjust the script but i can't. can you help me please?

 

Edited by drifox McMillan
Link to comment
Share on other sites

  • 2 years later...

I put several sliding door scripts on a helicopter, but some reversed the side of opening when I sat down, now with this script that Chic Aeon edited it worked perfectly with some modifications. it is very good to use door with glass to open at the same time. I wish you all good humor and good luck in all the good things in life SL and RL. 

Sliding Door Script * R1 Door

Sliding Door Script * R1 Window

string      OpenSound = "cb340647-9680-dd5e-49c0-86edfa01b3ac";

//Volume to play open sound, 0.0 is same as no sound, 1.0 is max
float       OpenVol = 1.0;

//Sound to play on close, either a UUID or a name in the door contents
//if a name, it must be exact. Leave at "" for no sound
string      CloseSound = "e7ff1054-003d-d134-66be-207573f2b535";

//Volume to play close sound, 0.0 is same as no sound, 1.0 is max
float       CloseVol = 1.0;

integer isOpen = FALSE;
vector originalPos;
vector defaultpos;
float slideBy = 1.0;
float TimeInterval = 15;
 
doOpenOrClose() 
{
  if (isOpen)
  {
    llTriggerSound(CloseSound, CloseVol); 
    llSetPos(originalPos);
    //llSetPos(defaultpos); 
    isOpen = FALSE;
    }
    else
    {
    llTriggerSound(OpenSound, OpenVol);  
    llSetPos(<originalPos.x - slideBy, originalPos.y, originalPos.z>); 
    //llSetPos(<defaultpos.x - slideBy, defaultpos.y, defaultpos.z>);
    // To move alon the y-axis, use this instead:
    // llSetPos();
    isOpen = TRUE;
    llSetTimerEvent(TimeInterval);
  }
}
 
default 
{
    state_entry() 
    {

        llListen(673, "", "", "");
        originalPos = llGetLocalPos();
        vector size = llGetScale();
        // Set up the amount to move by. Use size.y instead of size.x
        // if you want to slide along the y-axis.
        slideBy = size.x - 0.4;
    }
    
touch_start(integer agentCount)
{
    llSay(673,"doors");
    doOpenOrClose();
    }
    
timer() 
{
        llSetTimerEvent(0.0);
 
        /*
         * Close the door if it isn't already closed
         */
        if (isOpen)
            doOpenOrClose();
    }
//} 
    
listen(integer channel, string name, key id, string text)
    {
        if (text == "doors")
        {
            doOpenOrClose();
        }
    }
}

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 274 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...