Jump to content

Changing Which Side a Door Opens From


Czari Zenovka
 Share

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

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

Recommended Posts

I learned to build a free-standing wardrobe in a class years ago.  The door opened and closed with various animations between each open/close.  This has worked flawlessly, except - as one is facing the wardrobe, the door opens to the right, which seems opposite to RL doors.  I would really like to have the door open to the left.  I tried to read about the various door rotation designations in door scripts and ended up with a headache!  I'm hoping there is one or two parts of the script that will cause it to open to the left instead of right and many thanks in advance for any help.

The first thing that I find odd is that the door contains two door scripts.  I wouldn't think I need but one, however I tried taking each out and trying just one of the scripts, but without both of them the door doesn't open and shut. 

So the first script called "Closet Door" is:

default
{
    link_message(integer sender, integer n, string s, key k)
    {
        if ( s == "OPEN")
        {
            llSetLocalRot((rotation)llEuler2Rot(<0, 0, 300>*DEG_TO_RAD));
        }
        else if(s == "CLOSE")
        {
            llSetLocalRot((rotation)llEuler2Rot(<0, 0, 180>*DEG_TO_RAD));
        }
    }
}

 

The second script called "Closet Door (local rot)" is:

// improved door script by Ezhar Fairlight
// features: automatic closing, workaround for rotating out of position,
// doesn't mess up when moved, adjustable direction (inwards/outwards)
// updated for SL 1.1 damped rotations, small bugfix

// ********** USER SETTINGS HERE **********
float       TIMER_CLOSE = 5.0;      // automatically close the door after this many seconds,
                                    // set to 0 to disable

integer     DIRECTION   = 1;       // direction door opens in. Either 1 (outwards) or -1 (inwards);
// ********** END OF USER SETTINGS **********



integer     DOOR_OPEN   = 1;
integer     DOOR_CLOSE  = 2;

vector      mypos;      // 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)


SetLocalRot(rotation localrot) {
    llSetRot(localrot / ( (ZERO_ROTATION / llGetLocalRot()) * llGetRot()));
}

door(integer what) {
    rotation    delta;
    rotation    rot;

    llSetTimerEvent(0); // kill any running timers
    
    if ( what == DOOR_OPEN ) {
        delta = llGetLocalRot() * llEuler2Rot(<0, 0, DIRECTION * PI_BY_TWO> * 1.2);
        SetLocalRot(delta);
        
    } else if ( what == DOOR_CLOSE) {
        
        delta = llGetLocalRot() * llEuler2Rot(<0, 0, -DIRECTION * PI_BY_TWO> * 1.2);
        SetLocalRot(delta);
    }
}
        

default {   // is closed
    on_rez(integer start_param) { // reset, so we store the new position
        llResetScript();
    }
    
    state_entry() {
        mypos = llGetPos();     // remember where we're supposed to be
    }
    
    touch_start(integer total_number) {
        door(DOOR_OPEN);
        llMessageLinked(LINK_SET,0,"open",NULL_KEY);
        state is_open;
    }
    
    moving_end() {  // done moving me around, store new position
        mypos = llGetPos();
    }
}

state is_open {
    state_entry() {
        llSetTimerEvent(TIMER_CLOSE);
    }
    
    touch_start(integer num) {
        door(DOOR_CLOSE);
        llMessageLinked(LINK_SET,0,"close",NULL_KEY);        
        llSetPos(mypos);        // workaround for tiny movements during rotation
        
        state default;
    }
    
    timer() { // it's time to close the door
        door(DOOR_CLOSE);
        llMessageLinked(LINK_SET,0,"close",NULL_KEY);
    
        llSetPos(mypos);        // workaround for tiny movements during rotation
        
        state default;
    }
    
    moving_start() { // close door when door is being moved
        door(DOOR_CLOSE);
        llMessageLinked(LINK_SET,0,"close",NULL_KEY);
        
        state default;
    }
}

This one has notations that seem to be instructions of values to use...but I don't get it. :/

What values do I need to put where to get the door to open to the left, please?

 

Link to comment
Share on other sites

You have two choices:

(a) Follow the directions in script #2 and change

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

from 1 to -1.

(b) Flip the door upside down.

The two scripts are working together.  Script #1 gets its commands from script #2 by link_message

Link to comment
Share on other sites


Rolig Loon wrote:

You have two choices:

(a) Follow the directions in script #2 and change

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

from 1 to -1.

(b) Flip the door upside down.

The two scripts are working together.  Script #1 gets its commands from script #2 by link_message

Using method (a) I thought that would just make the door open toward the closet, not the hinge, per se, be on the opposite side.

(b) I tried moving the door around but I might have rotated it on another axis instead of flipping it.

Will give (a) a try.  If that doesn't do what I want, then will make sure I turn door upside down instead of rotatating that...although now that I think of it I'm pretty sure I did try upside down.  The door opened to the left then, but would not totally close back; it stayed partially open which is why I thought there might be some mysterious rotatation thing I need to try.

Thanks Rolig - my region had a restart but will go back in and play with this some more.

 

Link to comment
Share on other sites

To make it hinge on the opposite side, you would need to rotate the prim for the door 180 degrees on the vertical axis and move it to the other edge of the door frame. It's almost certainly a path cut prim, where the center of the prim is actually at the visible hinge 'edge', and the other half is cut away.

This also means the door might need to be retextured, if it is different on front and back, since what was facing out wil now be facing in.

In addition, you'd need to make that change in the script from positive to negative for the swing angle, so it opens outward in the new position.

===

You could instead rotate the door prim 180 degrees on the axis that goes front to back through the door, and move it to the opposite edge of the door frame. No script changes needed, but the textures on the front and back of the door will be upside down, so you will need edit that to flip them on the vertical axis of the door. That will work as long as there is no writing on the door, since the effect of flipping the texture will be to make it a mirror image of what it was before.

Link to comment
Share on other sites


Ceera Murakami wrote:

To make it hinge on the opposite side, you would need to rotate the prim for the door 180 degrees on the vertical axis and move it to the other edge of the door frame. It's almost certainly a path cut prim, where the center of the prim is actually at the visible hinge 'edge', and the other half is cut away.

This also means the door might need to be retextured, if it is different on front and back, since what was facing out wil now be facing in.

In addition, you'd need to make that change in the script from positive to negative for the swing angle, so it opens outward in the new position.

===

You could instead rotate the door prim 180 degrees on the axis that goes front to back through the door, and move it to the opposite edge of the door frame. No script changes needed, but the textures on the front and back of the door will be upside down, so you will need edit that to flip them on the vertical axis of the door. That will work as long as there is no writing on the door, since the effect of flipping the texture will be to make it a mirror image of what it was before.

Thanks, Ceera. :)  Yes, it is a path cut prim.  Thank you so much for the info...heading back into world and start tinkering with it again.

Link to comment
Share on other sites

I tried all the above instructions from both posts and, although I can get the door to open to the left, it does not close all the way.  (I am also using several animations within the closet.)  I am starting to understand the various configurations from playing around with it and will work more with it when I have more time.  At present it is something I am building for a hunt that starts soon, so will leave it opening to the right. ;)

Thank you, Rolig and Ceera, for your help.  I really appreciate it.

Link to comment
Share on other sites

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