Difference between revisions of "Teleport HUD"

From Second Life Wiki
Jump to navigation Jump to search
m (added info about no-script area hack and improved loop speeds)
m (Replaced <source> with <syntaxhighlight>)
 
(2 intermediate revisions by 2 users not shown)
Line 7: Line 7:
# Attach to HUD and enjoy!
# Attach to HUD and enjoy!


<lsl>
<syntaxhighlight lang="lsl2">
key owner;
key owner;
integer gotTPperms;
integer gotTPperms;
Line 30: Line 30:
             {
             {
                 llSetLinkPrimitiveParamsFast(index,
                 llSetLinkPrimitiveParamsFast(index,
                     [PRIM_COLOR, ALL_SIDES, ZERO_VECTOR, (float)TRUE,
                     [PRIM_COLOR, ALL_SIDES, ZERO_VECTOR, 1,
                     PRIM_COLOR, 3, <0.0, 1.0, 0.0>, (float)TRUE,
                     PRIM_COLOR, 3, <0.0, 1.0, 0.0>, 1,
                //  green and opaque floattext
                    //  green and opaque floattext
                     PRIM_TEXT, "click green button to close\n"
                     PRIM_TEXT, "click green button to close\n"
                         + "or select TP destination", <0.0, 1.0, 0.0>, (float)TRUE]);
                         + "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, (float)TRUE,
                     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, (float)TRUE]);
                     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, (float)TRUE,
                     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, (float)TRUE]);
                     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, (float)TRUE,
                     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, (float)TRUE]);
                     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, (float)TRUE,
                     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, (float)TRUE]);
                     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, (float)TRUE,
                     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, (float)TRUE]);
                     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, (float)TRUE,
                     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, (float)TRUE]);
                     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, (float)TRUE,
                     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, (float)TRUE]);
                     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, (float)TRUE,
                     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, (float)TRUE]);
                     PRIM_TEXT, llGetInventoryName(INVENTORY_LANDMARK, 7), orange, 1]);
             }
             }
         }
         }
Line 116: Line 116:
             {
             {
                 llSetLinkPrimitiveParamsFast(index,
                 llSetLinkPrimitiveParamsFast(index,
                     [PRIM_COLOR, ALL_SIDES, ZERO_VECTOR, (float)TRUE,
                     [PRIM_COLOR, ALL_SIDES, ZERO_VECTOR, 1,
                     PRIM_COLOR, 3, <1.0, 0.0, 0.0>, (float)TRUE,
                     PRIM_COLOR, 3, <1.0, 0.0, 0.0>, 1,
                //  red and opaque floattext
                    //  red and opaque floattext
                     PRIM_TEXT, "<~!~ TP HUD ~!~>", <1.0, 0.0, 0.0>, (float)TRUE]);
                     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, (float)FALSE,
                     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>,
                //  black and transparent floattext
                    //  black and transparent floattext
                     PRIM_TEXT, "", ZERO_VECTOR, (float)FALSE]);
                     PRIM_TEXT, "", ZERO_VECTOR, 0]);
             }
             }
         }
         }
Line 155: Line 155:
     {
     {
         llSetLinkPrimitiveParamsFast(LINK_ROOT,
         llSetLinkPrimitiveParamsFast(LINK_ROOT,
                [PRIM_NAME, "TP HUD for landmarks",
            [PRIM_NAME, "TP HUD for landmarks",
             PRIM_LINK_TARGET, 2,
             PRIM_LINK_TARGET, 2,
                PRIM_NAME, "tp1",
            PRIM_NAME, "tp1",
             PRIM_LINK_TARGET, 3,
             PRIM_LINK_TARGET, 3,
                PRIM_NAME, "tp2",
            PRIM_NAME, "tp2",
             PRIM_LINK_TARGET, 4,
             PRIM_LINK_TARGET, 4,
                PRIM_NAME, "tp3",
            PRIM_NAME, "tp3",
             PRIM_LINK_TARGET, 5,
             PRIM_LINK_TARGET, 5,
                PRIM_NAME, "tp4",
            PRIM_NAME, "tp4",
             PRIM_LINK_TARGET, 6,
             PRIM_LINK_TARGET, 6,
                PRIM_NAME, "tp5",
            PRIM_NAME, "tp5",
             PRIM_LINK_TARGET, 7,
             PRIM_LINK_TARGET, 7,
                PRIM_NAME, "tp6",
            PRIM_NAME, "tp6",
             PRIM_LINK_TARGET, 8,
             PRIM_LINK_TARGET, 8,
                PRIM_NAME, "tp7",
            PRIM_NAME, "tp7",
             PRIM_LINK_TARGET, 9,
             PRIM_LINK_TARGET, 9,
                PRIM_NAME, "tp8",]);
            PRIM_NAME, "tp8" ]);


         owner = llGetOwner();
         owner = llGetOwner();
Line 179: Line 179:
         toggle(isShowing);
         toggle(isShowing);


    //  request teleport perms and controls perms for no-script area hack
        //  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 220: Line 220:
     }
     }


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

Latest revision as of 11:41, 1 October 2022

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;
    }
}