Jump to content
  • 0

Add automatic door close to script


alaska87
 Share

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

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

Question

Is it possible to add a part in the script that makes the door close automatically?

 

/*//( v7-D Feebie Type 1 Hinge Script )--//*/
/*//-- Works At ANY Angle --//*/

/*//-- NOTES:
 works in ANY single prim door, linked or un-linked
 works in muti prim doors NOT linked to a larger structure
//*/

/*//-- REQUIREMENTS:
 a cut root prim, suggest cube, pathcut start=.125, end=.625
//*/

/*//-- CAVEAT:
 single prim doors are limited to 5m width
//*/

 /*//-- USERS MODIFY HERE v --//*/
integer gIntSwing = -105;
/*//-- use -# to reverse the direction of swing, eg. -90; --//*/


rotation gRotSwing;

default{
    state_entry(){
        gRotSwing = llEuler2Rot( < 0.0, (float)gIntSwing * DEG_TO_RAD, 0.0> );
    }
    
    touch_start( integer vInt ){
        llSetLocalRot( (gRotSwing = (ZERO_ROTATION / gRotSwing)) * llGetLocalRot() );
    }
}

/*//-- IF Redistributing as-is:
 Please leave script full permissions & include all comments
//*/

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0
6 hours ago, Lindal Kidd said:

I'm sure there is, since many doors do close automatically after a short period.  But since I am not a scripter, I'm not going to try to insert some code in your example.  Instead, here's a link to a library with a number of door scripts.  https://www.outworldz.com/cgi/freescripts.plx?Category=Door

 

1 hour ago, Fritigern Gothly said:

You will need to add a timer event which will execute llSetLocalRot(gRotSwing);

Thanks to both of you but I think this is too complicated for me. I'll just keep using my doors the old fashioned way. 😄

Link to comment
Share on other sites

  • 0
35 minutes ago, alaska87 said:

 

Thanks to both of you but I think this is too complicated for me. I'll just keep using my doors the old fashioned way. 😄

It's actually rather simple. I made the suggested additions to the script and removed a few comments for readability.

 

//-- USERS MODIFY HERE v --//
integer gIntSwing = -105;
//-- use -# to reverse the direction of swing, eg. -90; --//


rotation gRotSwing;

default{
    state_entry(){
        gRotSwing = llEuler2Rot( < 0.0, (float)gIntSwing * DEG_TO_RAD, 0.0> );
    }
    
    touch_start( integer vInt ){
        llSetLocalRot( (gRotSwing = (ZERO_ROTATION / gRotSwing)) * llGetLocalRot() );
        llSetTimerEvent(5); // Wait 5 seconds before executing the code in the timer() event.
    }
    
    timer()
    {
        llSetLocalRot(gRotSwing); // Restore the door's original rotation.
    }
}

Be aware that there are still some issues with this. For example, I have NOT tested this code in-world, but it should work™ and when it works it will be in a very basic way.

Link to comment
Share on other sites

  • 0
On 6/28/2019 at 11:27 PM, Fritigern Gothly said:

It's actually rather simple. I made the suggested additions to the script and removed a few comments for readability.

 


//-- USERS MODIFY HERE v --//
integer gIntSwing = -105;
//-- use -# to reverse the direction of swing, eg. -90; --//


rotation gRotSwing;

default{
    state_entry(){
        gRotSwing = llEuler2Rot( < 0.0, (float)gIntSwing * DEG_TO_RAD, 0.0> );
    }
    
    touch_start( integer vInt ){
        llSetLocalRot( (gRotSwing = (ZERO_ROTATION / gRotSwing)) * llGetLocalRot() );
        llSetTimerEvent(5); // Wait 5 seconds before executing the code in the timer() event.
    }
    
    timer()
    {
        llSetLocalRot(gRotSwing); // Restore the door's original rotation.
    }
}

Be aware that there are still some issues with this. For example, I have NOT tested this code in-world, but it should work™ and when it works it will be in a very basic way.

Sadly this did not work for me. It rotated the whole build instead of the door. 

 

Link to comment
Share on other sites

  • 0
1 hour ago, alaska87 said:

Sadly this did not work for me. It rotated the whole build instead of the door. 

 

Then it never worked for you. I didn't change anything which would cause that to happen.
However, try unlinking the door from the building and see if it still happens.

Alternatively find a different door script, there are many of them, lots of them can be found in one of the boxes full of freebie scripts which you can find at one of the hundreds freebie stores. Some of those free door scripts also have a configurable autoclose.

Link to comment
Share on other sites

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

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

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
 Share

×
×
  • Create New...