integer desired_controls;
default
{
on_rez(integer sp)
{
llResetScript();
}
state_entry()
{
llSitTarget(<0,0,1>,ZERO_ROTATION);
}
changed(integer change)
{
if (change & CHANGED_LINK)
{
if (llAvatarOnSitTarget() == llGetOwner())
{
llRequestPermissions (llGetOwner(),PERMISSION_TAKE_CONTROLS);
}
}
}
run_time_permissions(integer perms)
{
desired_controls =
CONTROL_FWD |
CONTROL_BACK |
CONTROL_LEFT |
CONTROL_RIGHT |
CONTROL_ROT_LEFT |
CONTROL_ROT_RIGHT |
CONTROL_UP |
CONTROL_DOWN;
if (perms & PERMISSION_TAKE_CONTROLS)
{
llTakeControls(desired_controls, TRUE, TRUE);
}
}
control(key id, integer down, integer new)
{
integer pressed = down & new;
integer held = down & ~new;
integer released = ~down & new;
if (pressed & CONTROL_UP)
llSetPos(llGetPos()+<0,0,3>
;if (pressed & CONTROL_DOWN)
llSetPos(llGetPos()+<0,0,-3>
;if (pressed & CONTROL_FWD)
llSetPos(llGetPos() + <3,0,0> * llGetRootRotation());
if (pressed & CONTROL_BACK)
llSetPos(llGetPos() + <-3,0,0> * llGetRootRotation());
if (pressed & CONTROL_ROT_LEFT)
llSetRot(llGetRot()+<-3,0,0,1>*llGetRootRotation());
if (pressed & CONTROL_ROT_RIGHT)
llSetRot(llGetRot()+<3,0,0,1>*llGetRootRotation());
if (pressed & CONTROL_LEFT)
llSetPos(llGetPos()+<0,-3,0>*llGetRootRotation());
if (pressed & CONTROL_RIGHT)
llSetPos(llGetPos()+<0,3,0>*llGetRootRotation());
}
}