Controller
CODE
default
{
state_entry()
{
llSitTarget(<0,0,.1>,ZERO_ROTATION);
}
changed(integer change)
{
//llSay(0,"changed event");
if(change & CHANGED_LINK)
{
//llSay(0,"someone is sitting on me");
key user=llAvatarOnSitTarget();
if(user != NULL_KEY)
{
//llSay(0,"requesting controls");
llRequestPermissions(user,PERMISSION_TAKE_CONTROLS|PERMISSION_TRIGGER_ANIMATION);
}
}
}
run_time_permissions(integer perm)
{
if (perm)
{
llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT, TRUE, FALSE);
}
}
control(key id, integer held, integer change)
{
integer pressed = held & change;
float time=llGetTime();
if(time >=.2)
{
llResetTime();
//llSay(0,"control event");
if(pressed & CONTROL_LEFT|CONTROL_ROT_LEFT)
{
llSay(2809,"left");
}
else if(pressed & CONTROL_RIGHT|CONTROL_ROT_RIGHT)
{
llSay(2809,"right");
}
else if(pressed & CONTROL_FWD)
{
llSay(2809,"up");
}
else if(pressed & CONTROL_BACK)
{
llSay(2809,"down");
}
}
}
}
Receiving (controlled prim)
CODE
default
{
state_entry()
{
llListen(2809,"",NULL_KEY,"");
}
listen(integer channel, string name, key id, string message)
{
if(message=="left")
{
llSetRot(llEuler2Rot(llRot2Euler(llGetRot())+<-PI/8,0,0>));
}
else if(message=="right")
{
llSetRot(llEuler2Rot(llRot2Euler(llGetRot())+<PI/8,0,0>));
}
}
}
I've messed with the order that the if statements fall in, and it seems to be firing the first rotational keypress clause no matter what. any idea why this is?