Jump to content

Linkable Multiprim Sliding Door


Recommended Posts

It ought to work.  iTouched will flip back and forth between TRUE and FALSE with each touch, turning the period of llSetTimerEvent from TIMER * 1 (= TIMER ) to TIMER * 0 (= 0.0).  Regardless of what it does to the timer, each time you click it will execute OpenShut(),which has its own sense switch (gON) to either open or close the door.  

Link to post
Share on other sites
  • 10 months later...
  • Replies 58
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

This simple script will operate a multiprim sliding door that you have linked to a larger structure. Each prim in the door must be named "DOOR", and none of the door prims may be the root prim of the

Just disable touches as soon as you touch the door and then re-enable them when the timer triggers.  There are several ways to do that.  Perhaps simplest ... touch_start(integer num) {      if (!i

OK...  There are many ways to do it.  Here's one: //Linkable Multiprim Sliding DOUBLE Door -- Rolig Loon -- February 2021 // All prims in the door must be contain the substring "DOOR", and none c

12 minutes ago, AHouseHunter said:

I cant seem to figure out how to get the door to close back... with each touch it keeps sliding in the initial direction

I can only guess that you have made a copying error or have been experimenting with a change that has bypassed or sabotaged the reversing toggle switch

gOn = (-1 )* gOn;

It's hard to tell which from a distance.

Link to post
Share on other sites
22 minutes ago, AHouseHunter said:

what is it I should be doing differently

Beats me.  Just to be sure that the forum software hadn't somehow messed up the posted script, I copied it out myself just now and put it into a simple two-prim mockup.  All I did, like you, was to provide a value for gDistance.

3f9a3cf56daed8d59dba233d6f3ebd89.gif

It works like a dream.  My script is in the untinted root prim in front of me.  The green sliding door is named DOOR.

Link to post
Share on other sites
  • 2 weeks later...

Hi there!

So, I'm not great with scripting and I had a question I didn't catch an answer to and couldn't seem to find. I'm trying to script a door that has two halves and have each half slide in a different direction. From what limited understanding I have, I can't figure out how to do that, and I can't seem to find any example of a script someone's made that would do it either. They all seem to only work with just 1 door at a time rather than two split halves. I know it's possible though, as i have a few doors that work this way, but unfortunately the scripts in all of them are No-Mod so I can't see how they did it.

EDIT: In the ones I have the doors are named something like DoorL DoorR, so I know it's calling the door description the same way the OP's script does. It's just that I can't tell how to call up two doors at a time, instead of just the one.

Edit 2:  So I found this script the OP posted, but I"m not sure how to change it to sliding from swing.:

 

Honestly comparing the two scripts I'm finding myself badly confused as to how you even tell the door to move side to side vs swing. I haven't really done much in the way of touching computer code in about 20 years or so, so while I understand a tiny bit here and there, I'm going a touch cross eyed trying to figure this one out.

More to the point, I don't understand how IntSwing would be replaced with something telling it to move sideways instead of rotate. Mostly because I don't understand how the OP's script in this thread is telling the door to move sideways instead. Is that the

Quote

float gDistance;

line? Like instead of intSwing = 90 you'd change it to Float gDistance = 1.0 ?

Edited by Kesslan Saramago
Link to post
Share on other sites

As I said in earlier posts in this thread. if you have many doors in a building, all you have to do is be sure that they all have different names.  You could have several instance of the script that controls them, or you could combine multiple instances into a single script that listens for many doors and controls them separately.  A double door might be a common example of that sort of combined script.  Touching either one of the two halves of the double door would activate both of them.

Link to post
Share on other sites
23 hours ago, Rolig Loon said:

As I said in earlier posts in this thread. if you have many doors in a building, all you have to do is be sure that they all have different names.  You could have several instance of the script that controls them, or you could combine multiple instances into a single script that listens for many doors and controls them separately.  A double door might be a common example of that sort of combined script.  Touching either one of the two halves of the double door would activate both of them.

Hmm, ok. I'm not sure how to do that but I'll take a stab at it!

Link to post
Share on other sites
50 minutes ago, Kesslan Saramago said:

I'm not sure how to do that but I'll take a stab at it!

OK...  There are many ways to do it.  Here's one:

//Linkable Multiprim Sliding DOUBLE Door -- Rolig Loon -- February 2021

// All prims in the door must be contain the substring "DOOR", and none can be the root prim of the linkset
// Links in the left hand door must be named "DOORL"; those in the right hand door must be named "DOORR" 

integer gON = 1; // Change to -1 to reverse the direction of opening
float gDistance = 1.3; // Adjust to set the distance the door should move long its local Y axis

list lRight;
list lLeft;

default
{
    state_entry()
    {
        integer i;
        while ( i < llGetNumberOfPrims() )  // Let's find all the door links and separate them, left and right
        {
            ++i;
            string Name = llGetLinkName(i);
            if (~llSubStringIndex(Name,"DOOR") )
            {
                if (llGetSubString(Name,-1,-1) == "R")
                {
                    lRight += [i];
                }
                else if (llGetSubString(Name, -1,-1) == "L")
                {
                    lLeft += [i];
                }
            }
        }
    }
    
    touch_start(integer total_number)
    {
        list AllLeft;
        list AllRight;
        integer j = llDetectedLinkNumber(0);
        if ( ~llListFindList(lRight,[j]) || ~llListFindList(lLeft,[j]) )  // Touched a door link
        {
            integer i;
            for (i=2;i<=llGetNumberOfPrims();++i)
            {
                if (~llListFindList(lRight,[i]))  //Accumulate all the Right door link movements
                {
                    list temp = llGetLinkPrimitiveParams(i,[PRIM_POSITION,PRIM_ROT_LOCAL]);
                    rotation local_rot = (rotation)llList2String(temp,1);
                    vector local_pos = ((vector)llList2String(temp,0)- llGetPos())/llGetRot();
                    AllRight += [34,i,PRIM_POSITION,local_pos + (<0.0,-1 * gDistance *gON,0.0>*local_rot),PRIM_ROTATION,local_rot/llGetRot()];
                }
                else if (~llListFindList(lLeft,[i]))  //Accumulate all the Left door link movements
                {
                    list temp = llGetLinkPrimitiveParams(i,[PRIM_POSITION,PRIM_ROT_LOCAL]);
                    rotation local_rot = (rotation)llList2String(temp,1);
                    vector local_pos = ((vector)llList2String(temp,0)- llGetPos())/llGetRot();
                    AllLeft += [34,i,PRIM_POSITION,local_pos + (<0.0,gDistance *gON,0.0>*local_rot),PRIM_ROTATION,local_rot/llGetRot()];
                }
            }
            llSetLinkPrimitiveParamsFast(LINK_SET,AllRight+AllLeft);    // Move all door links
            gON = (-1)*gON;
        }
    }
}

f5f03ca4d64f803dd6c04d0781746599.gif

Edited by Rolig Loon
  • Like 2
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...