Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Newbie Door Script Question

Beansidhe Blankes
Registered User
Join date: 30 Mar 2006
Posts: 1
05-11-2006 22:53
Ok this is the first script I have ever written and for some reason when I place it in an object it works fine for me. I have given it to a friend and when he places it in the door of a piece of furniture it shows a 4 degree degradation of the movement with each touch. Any help would be greatly appreciated.



closeDoor()
{
llSetPos(llGetLocalPos());
rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0,0,PI/-4>;);
rot = delta * rot;
llSetRot(rot);
llSleep(0.25);
rot = delta * rot;
llSetRot(rot);
}
integer is_open = FALSE;
default
{
state_entry()
{
}
touch_start (integer nullvar)
{
if (is_open)
{
is_open = FALSE;
llSetPos(llGetLocalPos());
rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0,0,PI/4>;);
rot = delta * rot;
llSetRot(rot);
llSleep(0.25);
rot = delta * rot;
llSetRot(rot);
}
else
{
is_open = TRUE;
closeDoor();
state default;
}
}
}
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
05-12-2006 02:13
hmm... I'm not sure but you change euler to rotation everytime. It might shift little by little. What about decided rotations in advance?

CODE
rotation rot1;
rotation rot2;
rotation rot3;

integer is_open = FALSE;

default
{
state_entry()
{
llSetStatus(STATUS_BLOCK_GRAB, TRUE); // If you don't want to drag it.
rot1 = llGetRot();
rotation delta = llEuler2Rot(<0,0,PI/-4>);
rot2 = delta * rot1;
rot3 = delta * rot2;
}
touch_start (integer nullvar)
{
if (is_open)
{
is_open = FALSE;
llSetPos(llGetLocalPos());
llSetRot(rot2);
llSleep(0.25);
llSetRot(rot1);
}
else
{
is_open = TRUE;
llSetPos(llGetLocalPos());
llSetRot(rot2);
llSleep(0.25);
llSetRot(rot3);
}
}
}
_____________________
:) Seagel Neville :)
Leonard Churchill
Just a Horse
Join date: 19 Oct 2005
Posts: 59
05-12-2006 09:19
Hmm. This looks very familiar. Could it be you want:

rotation delta = llEuler2Rot(<0,0,(-PI/4)>;);

not

rotation delta = llEuler2Rot(<0,0,PI/-4>;);

?
_____________________
"Give me a fish and I eat for a day. Teach me to fish and I eat for a lifetime." - Chinese Proverb

Always check the Wiki and/or Script Library
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
05-12-2006 11:04
Oh, I didn't know that. Thanks. :)
_____________________
:) Seagel Neville :)