08-20-2007 08:14
Hehe, found the problem. it was too far down the link order. Once I linked it next to the root in order it worked fine. I didn't expect that to happen. Learn something new all the time. Just glad I found the problem.
///////////////////////////////////////
Hello. The script below is in the door on a non phys vehicle. It works fine for about 2 uses of opening and closing, then stops. The only thing that continues to work is the llSetScale() part of it.
Is this a bug or have I done something silly with it? The vehicle is only 59 prims.
Any Ideas?
Here is the code for all you pro coders to look at.

CODE

rotation Inverse(rotation r)
{
r.x = -r.x;
r.y = -r.y;
r.z = -r.z;
return r;
}
vector CloseRot = <0.0,0.0,270.0>;
vector OpenRot = <180,298.15,90>; // change this, if it needs to open in different direction
// example <90.0,0.0,0.0> or <0.0,0.0,-90> etcetera
rotation open_rot;
rotation close_rot;
float move = -0.0; // this is to move object up and to the side so it looks like it pivots on the edge
// make the number bigger if the object is longer

default
{
state_entry()
{
open_rot = llEuler2Rot((DEG_TO_RAD * OpenRot));
close_rot = llEuler2Rot((DEG_TO_RAD * CloseRot));
}

touch_start(integer total_number)
{ // this is the open state
if (llDetectedKey(0) == llGetOwner())
{
llMessageLinked(LINK_ALL_OTHERS, -1024, "", NULL_KEY);
llSetScale (<2.4,2.363,2.363>);
vector pos = llGetLocalPos();
pos.z = pos.z + move;
pos.x = pos.x - move; // if the object moves to the side, change this into pos.y
// also if it moves to the front, change - into +
llSetPrimitiveParams([PRIM_ROTATION, open_rot * Inverse(Inverse(llGetLocalRot())*llGetRot()), PRIM_POSITION, pos]);
state open;
}
}
}

state open
{
touch_start(integer total_number)
{ // this is the closed state
if (llDetectedKey(0) == llGetOwner())
{
llMessageLinked(LINK_ALL_OTHERS, -1024, "", NULL_KEY);
llSetScale (<2.5,2.5,2.5>);
vector pos = llGetLocalPos();
pos.z = pos.z - move;
pos.x = pos.x + move; // if the object moves to the side, change this into pos.y
// also if it moves to the front, change - into +
llSetPrimitiveParams([PRIM_ROTATION, close_rot * Inverse(Inverse(llGetLocalRot())*llGetRot()), PRIM_POSITION, pos]);
state default;
}
}
}