Teleport HUD

From Second Life Wiki
Revision as of 00:01, 19 October 2012 by Kireji Haiku (Talk | contribs)

Jump to: navigation, search

Gridwide Teleport HUD (works in no-script areas)

  1. Link 9 prims.
  2. Drop this script.
  3. Add up to 8 landmarks.
  4. Attach to HUD and enjoy!

<lsl> key owner; integer gotTPperms; integer isShowing;

toggle(integer inputInteger) {

   if (inputInteger)
   {
       integer numOfPrims = llGetNumberOfPrims();
       rotation currentRot = llGetRot();
       vector white = <1.0, 1.0, 1.0>;
       vector orange = <1.0, 0.4, 0.0>;
       integer index = 1;//  root of linkset
       do
       {
           string linkName = llGetLinkName(index);
           if (linkName == "TP HUD for landmarks")
           {
               llSetLinkPrimitiveParamsFast(index,
                   [PRIM_COLOR, ALL_SIDES, ZERO_VECTOR, (float)TRUE,
                   PRIM_COLOR, 3, <0.0, 1.0, 0.0>, (float)TRUE,
               //  green and opaque floattext
                   PRIM_TEXT, "click green button to close\n"
                       + "or select TP destination", <0.0, 1.0, 0.0>, (float)TRUE]);
           }
           else if (linkName == "tp1")
           {
               llSetLinkPrimitiveParamsFast(index, [
                   PRIM_COLOR, ALL_SIDES, white, (float)TRUE,
                   PRIM_POSITION, <0.0, 0.0, -0.0475>*currentRot,
                   PRIM_SIZE, <0.025, 0.025, 0.010>,
                   PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 0), white, (float)TRUE]);
           }
           else if (linkName == "tp2")
           {
               llSetLinkPrimitiveParamsFast(index, [
                   PRIM_COLOR, ALL_SIDES, orange, (float)TRUE,
                   PRIM_POSITION, <0.0, 0.0, -0.0875>*currentRot,
                   PRIM_SIZE, <0.025, 0.025, 0.01>,
                   PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 1), orange, (float)TRUE]);
           }
           else if (linkName == "tp3")
           {
               llSetLinkPrimitiveParamsFast(index, [
                   PRIM_COLOR, ALL_SIDES, white, (float)TRUE,
                   PRIM_POSITION, <0.0, 0.0, -0.1275>*currentRot,
                   PRIM_SIZE, <0.025, 0.025, 0.01>,
                   PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 2), white, (float)TRUE]);
           }
           else if (linkName == "tp4")
           {
               llSetLinkPrimitiveParamsFast(index, [
                   PRIM_COLOR, ALL_SIDES, orange, (float)TRUE,
                   PRIM_POSITION, <0.0, 0.0, -0.1675>*currentRot,
                   PRIM_SIZE, <0.025, 0.025, 0.01>,
                   PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 3), orange, (float)TRUE]);
           }
           else if (linkName == "tp5")
           {
               llSetLinkPrimitiveParamsFast(index, [
                   PRIM_COLOR, ALL_SIDES, white, (float)TRUE,
                   PRIM_POSITION, <0.0, 0.0, -0.2075>*currentRot,
                   PRIM_SIZE, <0.025, 0.025, 0.01>,
                   PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 4), white, (float)TRUE]);
           }
           else if (linkName == "tp6")
           {
               llSetLinkPrimitiveParamsFast(index, [
                   PRIM_COLOR, ALL_SIDES, orange, (float)TRUE,
                   PRIM_POSITION, <0.0, 0.0, -0.2475>*currentRot,
                   PRIM_SIZE, <0.025, 0.025, 0.01>,
                   PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 5), orange, (float)TRUE]);
           }
           else if (linkName == "tp7")
           {
               llSetLinkPrimitiveParamsFast(index, [
                   PRIM_COLOR, ALL_SIDES, white, (float)TRUE,
                   PRIM_POSITION, <0.0, 0.0, -0.2875>*currentRot,
                   PRIM_SIZE, <0.025, 0.025, 0.01>,
                   PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 6), white, (float)TRUE]);
           }
           else if (linkName == "tp8")
           {
               llSetLinkPrimitiveParamsFast(index, [
                   PRIM_COLOR, ALL_SIDES, orange, (float)TRUE,
                   PRIM_POSITION, <0.0, 0.0, -0.3275>*currentRot,
                   PRIM_SIZE,<0.025, 0.025, 0.01>,
                   PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 7), orange, (float)TRUE]);
           }
       }
       while (++index <= numOfPrims);
   }
   else
   {
       rotation currentRot = llGetRot();
       integer numOfPrims = llGetNumberOfPrims();
       integer index = 1;//  root of linkset
       do
       {
           string linkName = llGetLinkName(index);
           if (linkName == "TP HUD for landmarks")
           {
               llSetLinkPrimitiveParamsFast(index,
                   [PRIM_COLOR, ALL_SIDES, ZERO_VECTOR, (float)TRUE,
                   PRIM_COLOR, 3, <1.0, 0.0, 0.0>, (float)TRUE,
               //  red and opaque floattext
                   PRIM_TEXT, "<~!~ TP HUD ~!~>", <1.0, 0.0, 0.0>, (float)TRUE]);
           }
           else if (linkName == "tp1" || linkName == "tp2"
                   || linkName == "tp3" || linkName == "tp4"
                   || linkName == "tp5" || linkName == "tp6"
                   || linkName == "tp7" || linkName == "tp8")
           {
               llSetLinkPrimitiveParamsFast(index, [
                   PRIM_COLOR, ALL_SIDES, ZERO_VECTOR, (float)FALSE,
                   PRIM_POSITION, ZERO_VECTOR*currentRot,
                   PRIM_SIZE, <0.01, 0.01, 0.01>,
               //  black and transparent floattext
                   PRIM_TEXT, "", ZERO_VECTOR, (float)FALSE]);
           }
       }
       while (++index <= numOfPrims);
   }

}

default {

   changed(integer change)
   {
       if (change & (CHANGED_OWNER | CHANGED_INVENTORY))
           llResetScript();
   }
   attach(key attached)
   {
       if (attached != NULL_KEY)
           llResetScript();
   }
   state_entry()
   {
       llSetLinkPrimitiveParamsFast(LINK_ROOT,
               [PRIM_NAME, "TP HUD for landmarks",
           PRIM_LINK_TARGET, 2,
               PRIM_NAME, "tp1",
           PRIM_LINK_TARGET, 3,
               PRIM_NAME, "tp2",
           PRIM_LINK_TARGET, 4,
               PRIM_NAME, "tp3",
           PRIM_LINK_TARGET, 5,
               PRIM_NAME, "tp4",
           PRIM_LINK_TARGET, 6,
               PRIM_NAME, "tp5",
           PRIM_LINK_TARGET, 7,
               PRIM_NAME, "tp6",
           PRIM_LINK_TARGET, 8,
               PRIM_NAME, "tp7",
           PRIM_LINK_TARGET, 9,
               PRIM_NAME, "tp8",]);
       owner = llGetOwner();
       gotTPperms = FALSE;
       isShowing = FALSE;
       toggle(isShowing);
   //  request teleport perms and controls perms for no-script area hack
       llRequestPermissions(owner, (PERMISSION_TELEPORT | PERMISSION_TAKE_CONTROLS));
   }
   touch_start(integer num_detected)
   {
       key id = llDetectedKey(0);
       string linkName = llGetLinkName(llDetectedLinkNumber(0));
       string tpDestination;
       if (id != owner)
           return;
       if (gotTPperms && linkName == "TP HUD for landmarks")
       {
           isShowing = !isShowing;
           toggle(isShowing);
       }
       else if (linkName == "tp1")
           tpDestination = llGetInventoryName(INVENTORY_LANDMARK, 0);
       else if (linkName == "tp2")
           tpDestination = llGetInventoryName(INVENTORY_LANDMARK, 1);
       else if (linkName == "tp3")
           tpDestination = llGetInventoryName(INVENTORY_LANDMARK, 2);
       else if (linkName == "tp4")
           tpDestination = llGetInventoryName(INVENTORY_LANDMARK, 3);
       else if (linkName == "tp5")
           tpDestination = llGetInventoryName(INVENTORY_LANDMARK, 4);
       else if (linkName == "tp6")
           tpDestination = llGetInventoryName(INVENTORY_LANDMARK, 5);
       else if (linkName == "tp7")
           tpDestination = llGetInventoryName(INVENTORY_LANDMARK, 6);
       else if (linkName == "tp8")
           tpDestination = llGetInventoryName(INVENTORY_LANDMARK, 7);
       if (tpDestination == "")
           llOwnerSay("Invalid destination!");
       else
           llTeleportAgent(owner, tpDestination, ZERO_VECTOR, ZERO_VECTOR);
   }

// no-script area hack

   control(key id,integer held, integer change)
   {
       return;
   }
   run_time_permissions(integer perm)
   {
       if (perm & PERMISSION_TAKE_CONTROLS)
           llTakeControls(CONTROL_UP,TRUE,TRUE);
       if (perm & PERMISSION_TELEPORT)
           gotTPperms = TRUE;
   }

} </lsl>