Jump to content
  • 0
Sign in to follow this  
alaska87

Add automatic door close to script

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
//*/

Share this post


Link to post
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. 😄

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
  • 0
4 hours ago, Nova Convair said:

If someone closes the door manually the timer will keep it open.

  

Quote

Be aware that there are still some issues with this

 

Share this post


Link to post
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. 

 

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
  • 0
Posted (edited)

Did you make the door the root? Because I think that’s what causes the house rotation. The root does not rotate, unless it is a very old script for unlinked doors.

Edited by Pamela Galli

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...