06-09-2005 13:58
this script is a gutted teleport script. I made heavy mods to it. that's why it has some wierd stuff. IT IS BY NO MEANS OPTIMIZED, nor is it meant to be. this release is just meant to force LL to fix the bug that makes it work as fast as possible.

vector dest = <66, 113, 18>;
integer success = FALSE;
float distance = 4;
float time;
integer requested;
string sim;

noPermission()
{
llSay(0, "Permissions not granted. Please try again";);
}
default
{
state_entry()
{
requested = (PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
llSetStatus(STATUS_PHANTOM, FALSE);
llVolumeDetect(TRUE);


llSetSitText("become invincible!";);
//llSetText(fltText, <1,1,1>, 1);
vector vsize = llGetAgentSize(llGetOwner());
float size = vsize.z;
llSetCameraAtOffset(<10, 0, 3>;);
llSetCameraEyeOffset(<-10, 0, 3>;);
llSitTarget(<0, 0, size/2>,<0,0,0,0>;);
//llSitTarget(dest-llGetPos() + <0, 0, size/2>, <0,0,0,1>;);
llSetTimerEvent(60);
llRequestPermissions(llGetOwner() ,requested);
}

on_rez(integer reznum)
{
integer permission = llGetPermissions() & requested;
if (permission != requested)
llResetScript();
}

run_time_permissions(integer perms)
{
perms = perms & requested;
if (perms != requested)
noPermission();
}

changed(integer change)
{
if (change == CHANGED_LINK)
{
// THIS IS THE PART THAT MAKES THIS SCRIOT WORK!!!
//
//

llVolumeDetect(TRUE);
//
//
//
sim = llGetRegionName();
key Avatar = llAvatarOnSitTarget();
if (Avatar != NULL_KEY)
{
if (Avatar != llGetOwner())
{
success = FALSE;
llUnSit(Avatar);
llSay(0, "Only the owner can use this sit cube defense. Build your own";);
}
else
{
integer permissions = llGetPermissions() & requested;
if (permissions == requested)
llTakeControls(
CONTROL_UP |
CONTROL_DOWN |
CONTROL_FWD |
CONTROL_BACK |
CONTROL_LEFT |
CONTROL_RIGHT |
CONTROL_ROT_LEFT |
CONTROL_ROT_RIGHT,
TRUE, FALSE);
else
noPermission();

//make the avatar look at least some semblance of normal
llStopAnimation("sit";);
llStartAnimation("stand";);
//Blank is a texture that is 100% alpha
llSetTexture("Blank", ALL_SIDES);
success = TRUE;
}
}
else
{
if (success)
{
llStopAnimation("sit";);
llStopAnimation("stand";);
integer permissions = llGetPermissions() & requested;
if (permissions == requested)
llReleaseControls();
llDie();
}
}
}

}

control(key id, integer level, integer edge)
{
time = llGetTime();
if (time > .25)
{
if (level & CONTROL_UP)
llSetPos(llGetPos() + <0, 0, distance>;);
else if (level & CONTROL_DOWN)
llSetPos(llGetPos() - <0, 0, distance>;);
if (level & CONTROL_FWD & ~CONTROL_BACK)
llSetPos(llGetPos() + llRot2Fwd(llGetRot())*distance);
else if (level & CONTROL_BACK & ~CONTROL_FWD)
llSetPos(llGetPos() - llRot2Fwd(llGetRot())*distance);
if (level & CONTROL_LEFT & ~CONTROL_RIGHT)
llSetPos(llGetPos() + llRot2Left(llGetRot())*distance);
else if (level & CONTROL_RIGHT & ~CONTROL_LEFT)
llSetPos(llGetPos() + -llRot2Left(llGetRot())*distance);
if (level & CONTROL_ROT_LEFT & ~CONTROL_ROT_RIGHT)
llSetRot(llEuler2Rot(llRot2Euler(llGetRot()) + <0, 0, PI/16>;));
else if (level & CONTROL_ROT_RIGHT & ~CONTROL_ROT_LEFT)
llSetRot(llEuler2Rot(llRot2Euler(llGetRot()) + <0, 0, -PI/16>;));


//this is so that it doesn't control too quickly for things like rotation.
llResetTime();

//finally this part allows the user to become phantom whenever a sim change is detected and prevent the need to rez a new one when you cross sims.
string currentSim = llGetRegionName();
if (sim != currentSim)
{
llVolumeDetect(TRUE);
sim = currentSim;
}

}
}

}