Jump to content
Sunbleached

Door Script - simplified configuration

Recommended Posts

Posted (edited)

Hello! Found this script on the forum. (Unfortunately I do not remember the author, I'm sorry, but thank you very much! I hope I didn’t spoil it.) And I am trying to simplify its configuration so that all changes are made at the beginning of the script. Did i do it right? What can be changed? How else can I simplify the configuration? Thank you!

string door_sound = "736a1c0a-4749-e7e9-6d28-a95d7fc10068";//sound uuid
integer intSwing = 90;//opening angle
float HINGE_X = -0.5;//hinge position by x axis
float HINGE_Y = 0.1;//hinge position by y axis
float HINGE_Z = 0.0;//hinge position by z axis

//choose opening axis:
float AXIS_X = 0.0;
float AXIS_Y = 0.0;
float AXIS_Z = intSwing;

rotation rotSwing;
vector vOffset;
default
{
        state_entry()
        {
                rotSwing = llEuler2Rot( < (float) AXIS_X, (float) AXIS_Y, (float) AXIS_Z > *
                        DEG_TO_RAD);
                vector size = llGetScale();
                vOffset = < size.x * HINGE_X, size.y * HINGE_Y, HINGE_Z > ;
        }
        touch_start(integer total_number)
        {
                llPlaySound(door_sound, 1.0);
                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;
        }
}

 

Edited by Sunbleached
  • Thanks 1

Share this post


Link to post
Share on other sites

That's someone's modification of the basic hinge script that Void Singer wrote and posted in the Scripting Library, here in the forums, several years ago.  It's possibly the most commonly used basic door script in SL. The best way to tell whether your own changes are "right" is to see if they do what you expected them to.  If so, you got it right.  There is no better test and no better judge.  Personally, I would just continue to use Void's original script and modify it on the fly as necessary, rather than trying to write a more complicated version that will look more like a Swiss Army knife, but that's my own personal choice.  We all learn by playing and testing ideas like this. Have fun with it.  😎

  • Thanks 1

Share this post


Link to post
Share on other sites
Posted (edited)
30 minutes ago, Rolig Loon said:

That's someone's modification of the basic hinge script that Void Singer wrote and posted in the Scripting Library, here in the forums, several years ago.  It's possibly the most commonly used basic door script in SL. The best way to tell whether your own changes are "right" is to see if they do what you expected them to.  If so, you got it right.  There is no better test and no better judge.  Personally, I would just continue to use Void's original script and modify it on the fly as necessary, rather than trying to write a more complicated version that will look more like a Swiss Army knife, but that's my own personal choice.  We all learn by playing and testing ideas like this. Have fun with it.  😎

Thanks for your reply!
There is a moment that is not very clear to me. Could you help, please? When I remove the line

integer intSwing = 90;//opening angle

and change the other line to

float AXIS_Z = 90;

the script still continues to work. So it looks like

float HINGE_X = -0.5;
float HINGE_Y = 0.1;
float HINGE_Z = 0.0;

float AXIS_X = 0.0;
float AXIS_Y = 0.0;
float AXIS_Z = 90;

Can I leave it like this?

Edited by Sunbleached

Share this post


Link to post
Share on other sites
42 minutes ago, Sunbleached said:

Can I leave it like this?

It obviously works.  Think through the logic.  As I said earlier,

1 hour ago, Rolig Loon said:

The best way to tell whether your own changes are "right" is to see if they do what you expected them to.  If so, you got it right.  There is no better test and no better judge. 

Figure things out for yourself and trust your own judgment.  And keep testing.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

I know it's not the purpose of the topic, but this script is wonderful, I just happened to come here when I was going to open a topic about door script, and it worked perfectly for me.

  • Like 1

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
Reply to this topic...

×   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.


×
×
  • Create New...