Im trying to script a single prim in an object to rotate either up or down when a prim button in the object is clicked. Problem is the object keeps hearing both commands no matter which button I click
I have stripped it down to 4 parts, the root prim, then prim #2 which I want to rotate, prim #3 is the up button and prim #4 is the down button
Trail and error and inexperiance have gotten me to this point:
I put this script in prim #4
***************************
string down = "down";
default
{
state_entry()
{
}
touch_start(integer total_number)
{
llMessageLinked(LINK_ROOT, 1, down, ""
;}
}
then a similar script in Prim #3
**************************************
string up = "up";
default
{
state_entry()
{
}
touch_start(integer total_number)
{
llMessageLinked(LINK_ROOT, 1, up, ""
;}
}
In the root prim I have 2 scripts acting as relays
******************************************d
efault
{
state_entry()
{
}
link_message (integer sender_num, integer num, string str, key id)
{
(sender_num == 3 & str == "up"
;llMessageLinked (LINK_ALL_CHILDREN, 1, "raise", NULL_KEY);
}
}
and
**********************************
default
{
state_entry()
{
}
link_message (integer sender_num, integer num, string str, key id)
{
(sender_num == 4 & str == "down"
;llMessageLinked (LINK_ALL_CHILDREN, 1, "lower", NULL_KEY);
}
}
THen in prim #2, the prim I want to rotate, I have these two scripts
****************************************************
integer angle_increment = 5;
integer no_of_inclination_moves = 1;
default
{
state_entry()
{
}
link_message( integer sender_num, integer num, string str, key id)
{
(sender_num == 1 & str == "lower"
;{
llWhisper( 0, "Lowering 5 Degrees"
;rotation z_inc = llEuler2Rot( <0, angle_increment * DEG_TO_RAD, 0> );
rotation new_rot = z_inc*llGetRot();
no_of_inclination_moves = no_of_inclination_moves + 1;
llSetRot(new_rot);
integer ma = angle_increment* no_of_inclination_moves;
}
}
}
************************************
integer angle_increment = 5;
integer no_of_inclination_moves = 1;
default
{
state_entry()
{
}
link_message( integer sender_num, integer num, string str, key id)
{
(sender_num == 1 & str == "raise"
;{
llWhisper( 0, "Raising 5 Degrees"
;rotation z_inc = llEuler2Rot( -(<0, angle_increment * DEG_TO_RAD, 0>
);rotation new_rot = z_inc*llGetRot();
no_of_inclination_moves = no_of_inclination_moves - 1;
llSetRot(new_rot);
integer ma = angle_increment* no_of_inclination_moves;
}
}
}
When I click either of the buttons though prim #3 does the commands of both buttons, so it goes up and right back down. I know this might seem a round about way to do this but this is just me trying to figure it out from scratch a bit. Can someone tell me what Im doing wrong?
Thanks!
