Difference between revisions of "Teleport HUD"

From Second Life Wiki
Jump to navigation Jump to search
(replaced example script with gridwide teleport HUD script using the new llTeleportAgent function)
(Correct syntax error. Avoid misrepresentative (float)TRUE / (float)FALSE)
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{LSL Header}}
{{LSL Header}}
== Gridwide Teleport HUD ==
== Gridwide Teleport HUD (works in no-script areas) ==


# Link 9 prims.
# Link 9 prims.
Line 7: Line 7:
# Attach to HUD and enjoy!
# Attach to HUD and enjoy!


<lsl>
<source lang="lsl2">
key owner;
key owner;
integer gotTPperms;
integer gotTPperms;
Line 22: Line 22:
         vector orange = <1.0, 0.4, 0.0>;
         vector orange = <1.0, 0.4, 0.0>;


         integer index;
         integer index = 1;//  root of linkset
         while (index <= numOfPrims)
         do
         {
         {
             string linkName = llGetLinkName(index);
             string linkName = llGetLinkName(index);
Line 30: Line 30:
             {
             {
                 llSetLinkPrimitiveParamsFast(index,
                 llSetLinkPrimitiveParamsFast(index,
                     [PRIM_COLOR, ALL_SIDES, ZERO_VECTOR, 1.0,
                     [PRIM_COLOR, ALL_SIDES, ZERO_VECTOR, 1,
                     PRIM_COLOR, 3, <0.0, 1.0, 0.0>, 1.0,
                     PRIM_COLOR, 3, <0.0, 1.0, 0.0>, 1,
                     PRIM_TEXT, "click green button to close\nor select TP destination", <0.0, 1.0, 0.0>, 1.0]);
                    //  green and opaque floattext
                     PRIM_TEXT, "click green button to close\n"
                        + "or select TP destination", <0.0, 1.0, 0.0>, 1]);
             }
             }
             else if (linkName == "tp1")
             else if (linkName == "tp1")
             {
             {
                 llSetLinkPrimitiveParamsFast(index, [
                 llSetLinkPrimitiveParamsFast(index, [
                     PRIM_COLOR, ALL_SIDES, white, 1.0,
                     PRIM_COLOR, ALL_SIDES, white, 1,
                     PRIM_POSITION, <0.0, 0.0, -0.0475>*currentRot,
                     PRIM_POSITION, <0.0, 0.0, -0.0475>*currentRot,
                     PRIM_SIZE, <0.025, 0.025, 0.010>,
                     PRIM_SIZE, <0.025, 0.025, 0.010>,
                     PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 0), white, 1.0]);
                     PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 0), white, 1]);
             }
             }
             else if (linkName == "tp2")
             else if (linkName == "tp2")
             {
             {
                 llSetLinkPrimitiveParamsFast(index, [
                 llSetLinkPrimitiveParamsFast(index, [
                     PRIM_COLOR, ALL_SIDES, orange, 1.0,
                     PRIM_COLOR, ALL_SIDES, orange, 1,
                     PRIM_POSITION, <0.0, 0.0, -0.0875>*currentRot,
                     PRIM_POSITION, <0.0, 0.0, -0.0875>*currentRot,
                     PRIM_SIZE, <0.025, 0.025, 0.01>,
                     PRIM_SIZE, <0.025, 0.025, 0.01>,
                     PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 1), orange, 1.0]);
                     PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 1), orange, 1]);
             }
             }
             else if (linkName == "tp3")
             else if (linkName == "tp3")
             {
             {
                 llSetLinkPrimitiveParamsFast(index, [
                 llSetLinkPrimitiveParamsFast(index, [
                     PRIM_COLOR, ALL_SIDES, white, 1.0,
                     PRIM_COLOR, ALL_SIDES, white, 1,
                     PRIM_POSITION, <0.0, 0.0, -0.1275>*currentRot,
                     PRIM_POSITION, <0.0, 0.0, -0.1275>*currentRot,
                     PRIM_SIZE, <0.025, 0.025, 0.01>,
                     PRIM_SIZE, <0.025, 0.025, 0.01>,
                     PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 2), white, 1.0]);
                     PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 2), white, 1]);
             }
             }
             else if (linkName == "tp4")
             else if (linkName == "tp4")
             {
             {
                 llSetLinkPrimitiveParamsFast(index, [
                 llSetLinkPrimitiveParamsFast(index, [
                     PRIM_COLOR, ALL_SIDES, orange, 1.0,
                     PRIM_COLOR, ALL_SIDES, orange, 1,
                     PRIM_POSITION, <0.0, 0.0, -0.1675>*currentRot,
                     PRIM_POSITION, <0.0, 0.0, -0.1675>*currentRot,
                     PRIM_SIZE, <0.025, 0.025, 0.01>,
                     PRIM_SIZE, <0.025, 0.025, 0.01>,
                     PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 3), orange, 1.0]);
                     PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 3), orange, 1]);
             }
             }
             else if (linkName == "tp5")
             else if (linkName == "tp5")
             {
             {
                 llSetLinkPrimitiveParamsFast(index, [
                 llSetLinkPrimitiveParamsFast(index, [
                     PRIM_COLOR, ALL_SIDES, white, 1.0,
                     PRIM_COLOR, ALL_SIDES, white, 1,
                     PRIM_POSITION, <0.0, 0.0, -0.2075>*currentRot,
                     PRIM_POSITION, <0.0, 0.0, -0.2075>*currentRot,
                     PRIM_SIZE, <0.025, 0.025, 0.01>,
                     PRIM_SIZE, <0.025, 0.025, 0.01>,
                     PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 4), white, 1.0]);
                     PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 4), white, 1]);
             }
             }
             else if (linkName == "tp6")
             else if (linkName == "tp6")
             {
             {
                 llSetLinkPrimitiveParamsFast(index, [
                 llSetLinkPrimitiveParamsFast(index, [
                     PRIM_COLOR, ALL_SIDES, orange, 1.0,
                     PRIM_COLOR, ALL_SIDES, orange, 1,
                     PRIM_POSITION, <0.0, 0.0, -0.2475>*currentRot,
                     PRIM_POSITION, <0.0, 0.0, -0.2475>*currentRot,
                     PRIM_SIZE, <0.025, 0.025, 0.01>,
                     PRIM_SIZE, <0.025, 0.025, 0.01>,
                     PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 5), orange, 1.0]);
                     PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 5), orange, 1]);
             }
             }
             else if (linkName == "tp7")
             else if (linkName == "tp7")
             {
             {
                 llSetLinkPrimitiveParamsFast(index, [
                 llSetLinkPrimitiveParamsFast(index, [
                     PRIM_COLOR, ALL_SIDES, white, 1.0,
                     PRIM_COLOR, ALL_SIDES, white, 1,
                     PRIM_POSITION, <0.0, 0.0, -0.2875>*currentRot,
                     PRIM_POSITION, <0.0, 0.0, -0.2875>*currentRot,
                     PRIM_SIZE, <0.025, 0.025, 0.01>,
                     PRIM_SIZE, <0.025, 0.025, 0.01>,
                     PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 6), white, 1.0]);
                     PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 6), white, 1]);
             }
             }
             else if (linkName == "tp8")
             else if (linkName == "tp8")
             {
             {
                 llSetLinkPrimitiveParamsFast(index, [
                 llSetLinkPrimitiveParamsFast(index, [
                     PRIM_COLOR, ALL_SIDES, orange, 1.0,
                     PRIM_COLOR, ALL_SIDES, orange, 1,
                     PRIM_POSITION, <0.0, 0.0, -0.3275>*currentRot,
                     PRIM_POSITION, <0.0, 0.0, -0.3275>*currentRot,
                     PRIM_SIZE,<0.025, 0.025, 0.01>,
                     PRIM_SIZE,<0.025, 0.025, 0.01>,
                     PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 7), orange, 1.0]);
                     PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 7), orange, 1]);
             }
             }
            index++;
         }
         }
        while (++index <= numOfPrims);
     }
     }
     else
     else
Line 107: Line 108:
         integer numOfPrims = llGetNumberOfPrims();
         integer numOfPrims = llGetNumberOfPrims();


         integer index;
         integer index = 1;//  root of linkset
         while (index <= numOfPrims)
         do
         {
         {
             string linkName = llGetLinkName(index);
             string linkName = llGetLinkName(index);
Line 115: Line 116:
             {
             {
                 llSetLinkPrimitiveParamsFast(index,
                 llSetLinkPrimitiveParamsFast(index,
                     [PRIM_COLOR, ALL_SIDES, ZERO_VECTOR, 1.0,
                     [PRIM_COLOR, ALL_SIDES, ZERO_VECTOR, 1,
                     PRIM_COLOR, 3, <1.0, 0.0, 0.0>, 1.0,
                     PRIM_COLOR, 3, <1.0, 0.0, 0.0>, 1,
                     PRIM_TEXT, "<~!~ TP HUD ~!~>", <1.0, 0.0, 0.0>, 1.0]);
                    //  red and opaque floattext
                     PRIM_TEXT, "<~!~ TP HUD ~!~>", <1.0, 0.0, 0.0>, 1]);
             }
             }
             else if (linkName == "tp1" || linkName == "tp2"
             else if (linkName == "tp1" || linkName == "tp2"
                    || linkName == "tp3" || linkName == "tp4"
                || linkName == "tp3" || linkName == "tp4"
                    || linkName == "tp5" || linkName == "tp6"
                || linkName == "tp5" || linkName == "tp6"
                    || linkName == "tp7" || linkName == "tp8")
                || linkName == "tp7" || linkName == "tp8")
             {
             {
                 llSetLinkPrimitiveParamsFast(index, [
                 llSetLinkPrimitiveParamsFast(index, [
                     PRIM_COLOR, ALL_SIDES, ZERO_VECTOR, 0.0,
                     PRIM_COLOR, ALL_SIDES, ZERO_VECTOR, 0,
                     PRIM_POSITION, ZERO_VECTOR*currentRot,
                     PRIM_POSITION, ZERO_VECTOR*currentRot,
                     PRIM_SIZE, <0.01, 0.01, 0.01>,
                     PRIM_SIZE, <0.01, 0.01, 0.01>,
                     PRIM_TEXT, "", ZERO_VECTOR, 0.0]);
                    //  black and transparent floattext
                     PRIM_TEXT, "", ZERO_VECTOR, 0]);
             }
             }
            index++;
         }
         }
        while (++index <= numOfPrims);
     }
     }
}
}
Line 154: Line 156:
         llSetLinkPrimitiveParamsFast(LINK_ROOT,
         llSetLinkPrimitiveParamsFast(LINK_ROOT,
             [PRIM_NAME, "TP HUD for landmarks",
             [PRIM_NAME, "TP HUD for landmarks",
             PRIM_LINK_TARGET, 2, PRIM_NAME, "tp1",
             PRIM_LINK_TARGET, 2,
             PRIM_LINK_TARGET, 3, PRIM_NAME, "tp2",
            PRIM_NAME, "tp1",
             PRIM_LINK_TARGET, 4, PRIM_NAME, "tp3",
             PRIM_LINK_TARGET, 3,
             PRIM_LINK_TARGET, 5, PRIM_NAME, "tp4",
            PRIM_NAME, "tp2",
             PRIM_LINK_TARGET, 6, PRIM_NAME, "tp5",
             PRIM_LINK_TARGET, 4,
             PRIM_LINK_TARGET, 7, PRIM_NAME, "tp6",
            PRIM_NAME, "tp3",
             PRIM_LINK_TARGET, 8, PRIM_NAME, "tp7",
             PRIM_LINK_TARGET, 5,
             PRIM_LINK_TARGET, 9, PRIM_NAME, "tp8",]);
            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();
         owner = llGetOwner();
Line 169: Line 179:
         toggle(isShowing);
         toggle(isShowing);


        //  request teleport perms and controls perms for no-script area hack
         llRequestPermissions(owner, (PERMISSION_TELEPORT | PERMISSION_TAKE_CONTROLS));
         llRequestPermissions(owner, (PERMISSION_TELEPORT | PERMISSION_TAKE_CONTROLS));
     }
     }
Line 209: Line 220:
     }
     }


    //  no-script area hack
     control(key id,integer held, integer change)
     control(key id,integer held, integer change)
     {
     {
Line 222: Line 234:
     }
     }
}
}
</lsl>
</source>
{{LSLC|Library|Teleport HUD}}
{{LSLC|Library|Teleport HUD}}

Revision as of 07:51, 21 January 2016

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!
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, 1,
                    PRIM_COLOR, 3, <0.0, 1.0, 0.0>, 1,
                    //  green and opaque floattext
                    PRIM_TEXT, "click green button to close\n"
                        + "or select TP destination", <0.0, 1.0, 0.0>, 1]);
            }
            else if (linkName == "tp1")
            {
                llSetLinkPrimitiveParamsFast(index, [
                    PRIM_COLOR, ALL_SIDES, white, 1,
                    PRIM_POSITION, <0.0, 0.0, -0.0475>*currentRot,
                    PRIM_SIZE, <0.025, 0.025, 0.010>,
                    PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 0), white, 1]);
            }
            else if (linkName == "tp2")
            {
                llSetLinkPrimitiveParamsFast(index, [
                    PRIM_COLOR, ALL_SIDES, orange, 1,
                    PRIM_POSITION, <0.0, 0.0, -0.0875>*currentRot,
                    PRIM_SIZE, <0.025, 0.025, 0.01>,
                    PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 1), orange, 1]);
            }
            else if (linkName == "tp3")
            {
                llSetLinkPrimitiveParamsFast(index, [
                    PRIM_COLOR, ALL_SIDES, white, 1,
                    PRIM_POSITION, <0.0, 0.0, -0.1275>*currentRot,
                    PRIM_SIZE, <0.025, 0.025, 0.01>,
                    PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 2), white, 1]);
            }
            else if (linkName == "tp4")
            {
                llSetLinkPrimitiveParamsFast(index, [
                    PRIM_COLOR, ALL_SIDES, orange, 1,
                    PRIM_POSITION, <0.0, 0.0, -0.1675>*currentRot,
                    PRIM_SIZE, <0.025, 0.025, 0.01>,
                    PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 3), orange, 1]);
            }
            else if (linkName == "tp5")
            {
                llSetLinkPrimitiveParamsFast(index, [
                    PRIM_COLOR, ALL_SIDES, white, 1,
                    PRIM_POSITION, <0.0, 0.0, -0.2075>*currentRot,
                    PRIM_SIZE, <0.025, 0.025, 0.01>,
                    PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 4), white, 1]);
            }
            else if (linkName == "tp6")
            {
                llSetLinkPrimitiveParamsFast(index, [
                    PRIM_COLOR, ALL_SIDES, orange, 1,
                    PRIM_POSITION, <0.0, 0.0, -0.2475>*currentRot,
                    PRIM_SIZE, <0.025, 0.025, 0.01>,
                    PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 5), orange, 1]);
            }
            else if (linkName == "tp7")
            {
                llSetLinkPrimitiveParamsFast(index, [
                    PRIM_COLOR, ALL_SIDES, white, 1,
                    PRIM_POSITION, <0.0, 0.0, -0.2875>*currentRot,
                    PRIM_SIZE, <0.025, 0.025, 0.01>,
                    PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 6), white, 1]);
            }
            else if (linkName == "tp8")
            {
                llSetLinkPrimitiveParamsFast(index, [
                    PRIM_COLOR, ALL_SIDES, orange, 1,
                    PRIM_POSITION, <0.0, 0.0, -0.3275>*currentRot,
                    PRIM_SIZE,<0.025, 0.025, 0.01>,
                    PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 7), orange, 1]);
            }
        }
        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, 1,
                    PRIM_COLOR, 3, <1.0, 0.0, 0.0>, 1,
                    //  red and opaque floattext
                    PRIM_TEXT, "<~!~ TP HUD ~!~>", <1.0, 0.0, 0.0>, 1]);
            }
            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, 0,
                    PRIM_POSITION, ZERO_VECTOR*currentRot,
                    PRIM_SIZE, <0.01, 0.01, 0.01>,
                    //  black and transparent floattext
                    PRIM_TEXT, "", ZERO_VECTOR, 0]);
            }
        }
        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;
    }
}