Jump to content

Help to make both doors open when one is touched


Sweet2770
 Share

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

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

Recommended Posts

Hey SL

Im trying to find out if both doors can open at the same time when touching only one of them with this script.

there is one script in each the doors. The doors in a building and the whole building is linked together.

anyone knows how to do that and would help out? :)

 

integer intSwing =90;
rotation rotSwing;
vector vOffset;

default{    

    state_entry(){
           rotSwing = llEuler2Rot(<0.0,0.0,(float)intSwing>*DEG_TO_RAD);       
           vector size = llGetScale();       
           vOffset = <(size.x*-0.5),(size.y*-0.5),0.0>;
               
       }    

        touch_start(integer total_number){
            list l = llGetPrimitiveParams([PRIM_POS_LOCAL,PRIM_ROT_LOCAL]);
            vector v = llList2Vector(l,0);
            rotation r = llList2Rot(l,1);
            llSetPrimitiveParams([PRIM_POS_LOCAL,v+(vOffset-vOffset * rotSwing)*r,PRIM_ROT_LOCAL,rotSwing*r]);
            
            rotSwing.s*=-1;             
        }
}

Link to comment
Share on other sites

You can use the special constant PRIM_LINK_TARGET in the parameters rules list to (as the name implies) target other links with llSetPrimitiveParams function call. This allows you to make a more complex rules list that can simultaneously affect multiple prims at the same time in the linkset.

//Demo - link 3 prims together and place this in the root.
default
{
    touch_start(integer total_number)
    {
        llSetPrimitiveParams([
            PRIM_LINK_TARGET, 2,
                PRIM_COLOR, ALL_SIDES, <1.0, 0.0, 0.0>, 1.0,
            PRIM_LINK_TARGET, 3,
                PRIM_COLOR, ALL_SIDES, <0.0, 1.0, 0.0>, 1.0
        ]);
    }
}

Normally, llSetPrimitiveParams can only target the same prim the script is in. But with the addition of PRIM_LINK_TARGET, you can make it instead target different links. See also llSetLinkPrimitiveParamsFast. In the example above, the script would be in the root, but you can observe how it only changes the color of links 2 and 3 and doesn't alter the root at all.

You will need to discover the link numbers for the doors you wish to move, and should probably use llDetectedLinkNumber in the touch_start event as a filter to only try opening/closing the door when those specific links are clicked.

As for automatic closing, see llSetTimerEvent. It's fairly straightforward: Start the timer when the door(s) are opened. In the accompanying timer event, stop the timer (so it doesn't keep running forever) and close the doors similar to how they were opened. It might be a good idea to add a global variable to keep track of the door's state and check/update that accordingly as well.

Edited by Fenix Eldritch
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 244 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...