Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Put vector of the location you want the teleporting to go to in the description
- // example: <113.05876, 202.18401, 19.97662>
- vector HomeSpot; // where I should go back; updated every teleport
- default
- {
- state_entry()
- {
- // set a sit target... we have to do this to trigger
- // a changed event
- llSitTarget(<0.0,0.0,0.1>, ZERO_ROTATION);
- // and a nice sit text, which is completely ignored by viewer 2.
- llSetSitText("Teleport");
- // make sure no one's sitting.....
- llUnSit(llAvatarOnSitTarget());
- }
- changed(integer change)
- {
- if (change & CHANGED_LINK)
- { // if a link change occurs (sit or unsit)
- if(llAvatarOnSitTarget() != NULL_KEY)
- {
- vector targetVector = (vector)llGetObjectDesc(); // where are we headed?
- if (targetVector != ZERO_VECTOR)
- {
- llSetStatus(STATUS_PHANTOM,TRUE);
- HomeSpot = llGetPos(); // record current position for return
- if (llSetRegionPos(targetVector))
- {
- // the teleporter moved to the target
- llUnSit(llAvatarOnSitTarget()); // unsit him
- llSetRegionPos(HomeSpot); // teleport back to old position
- }
- else
- {
- // teleporter didn't go where it should have.
- llUnSit(llAvatarOnSitTarget()); // unsit him
- llOwnerSay("This teleporter was unable to move to the destination.");
- }
- llSetStatus(STATUS_PHANTOM,FALSE);
- }
- else llOwnerSay("This teleporter has a bad destination in its description.");
- }
- // if someone links the object, we reset the script.
- else llResetScript();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement