Advertisement
LethBaumann

Simple Teleporter

Sep 9th, 2018
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Put vector of the location you want the teleporting to go to in the description
  2. // example: <113.05876, 202.18401, 19.97662>
  3.  
  4. vector HomeSpot; // where I should go back; updated every teleport
  5.  
  6. default
  7. {
  8.     state_entry()
  9.     {
  10.         // set a sit target... we have to do this to trigger
  11.         // a changed event
  12.         llSitTarget(<0.0,0.0,0.1>, ZERO_ROTATION);
  13.         // and a nice sit text, which is completely ignored by viewer 2.
  14.         llSetSitText("Teleport");
  15.         // make sure no one's sitting.....
  16.         llUnSit(llAvatarOnSitTarget());
  17.     }
  18.  
  19.     changed(integer change)
  20.     {
  21.         if (change & CHANGED_LINK)
  22.         {  // if a link change occurs (sit or unsit)
  23.             if(llAvatarOnSitTarget() != NULL_KEY)
  24.             {
  25.                 vector targetVector = (vector)llGetObjectDesc(); // where are we headed?
  26.                 if (targetVector != ZERO_VECTOR)
  27.                 {
  28.                     llSetStatus(STATUS_PHANTOM,TRUE);
  29.                     HomeSpot = llGetPos();  // record current position for return
  30.                     if (llSetRegionPos(targetVector))
  31.                     {
  32.                         // the teleporter moved to the target
  33.                         llUnSit(llAvatarOnSitTarget()); // unsit him
  34.                         llSetRegionPos(HomeSpot);  // teleport back to old position
  35.                     }
  36.                     else
  37.                     {
  38.                         // teleporter didn't go where it should have.
  39.                         llUnSit(llAvatarOnSitTarget()); // unsit him
  40.                         llOwnerSay("This teleporter was unable to move to the destination.");
  41.                     }
  42.                     llSetStatus(STATUS_PHANTOM,FALSE);
  43.                 }
  44.                 else llOwnerSay("This teleporter has a bad destination in its description.");
  45.             }
  46.             // if someone links the object, we reset the script.
  47.             else llResetScript();
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement