Object 1<===>Prim <===>Object2
The above three (Object1, Prim and Object2 is not link to each other).
Now, Object1 has the script below:
vector startPos;
float x_dist = 0.5;
float y_dist = 0.0;
float z_dist = 0.0;
default
{
state_entry()
{
startPos = llGetPos();
llListen(0, "", "", "moving close" );
llListen(0, "", "", "moving open"
;}
on_rez(integer num)
{
llResetScript();
}
listen(integer number, string name, key id, string message)
{
if(message == "moving open"

{
vector increment;
if (increment = <x_dist, y_dist, z_dist>

{
vector newPos = startPos - increment;
llSetPos(newPos);
}
vector newPos;
newPos = llGetPos();
vector y_decrement = <x_dist, 0.9, z_dist>;
vector yrepoPos = startPos - y_decrement;
llSetPos(yrepoPos);
}
if(message == "moving close"

{
state close;
}
}
}
state close
{
state_entry()
{
startPos = llGetPos();
vector decrement = <x_dist, y_dist, z_dist>;
vector repoPos = startPos + decrement;
llSetPos(repoPos);
repoPos = llGetPos();
vector y_decrement = <x_dist, 0.9, z_dist>;
vector yrepoPos = startPos + y_decrement;
llSetPos(yrepoPos);
llResetScript();
}
}
Object2 has the script below:
vector startPos;
float x_dist = 0.5;
float y_dist = 0.0;
float z_dist = 0.0;
default
{
state_entry()
{
startPos = llGetPos();
llListen(0, "", "", "moving close" );
llListen(0, "", "", "moving open"
;}
on_rez(integer num)
{
llResetScript();
}
listen(integer number, string name, key id, string message)
{
if(message == "moving open"

{
vector increment;
if (increment = <x_dist, y_dist, z_dist>

{
vector newPos = startPos + increment;
llSetPos(newPos);
}
vector newPos;
newPos = llGetPos();
vector y_decrement = <x_dist, -0.9, z_dist>;
vector yrepoPos = startPos + y_decrement;
llSetPos(yrepoPos);
}
if(message == "moving close"

{
state close;
}
}
}
state close
{
state_entry()
{
startPos = llGetPos();
vector decrement = <x_dist, y_dist, z_dist>;
vector repoPos = startPos - decrement;
llSetPos(repoPos);
repoPos = llGetPos();
vector y_decrement = <x_dist, -0.9, z_dist>;
vector yrepoPos = startPos - y_decrement;
llSetPos(yrepoPos);
llResetScript();
}
}
Now, the problem is, when I rotate the whole stuff and then run the script the scripted object will not run relative to the position. How can I fix that? Thanks in advance...