Difference between revisions of "Teleport HUD"
Jump to navigation
Jump to search
Omei Qunhua (talk | contribs) (Correct syntax error. Avoid misrepresentative (float)TRUE / (float)FALSE) |
m (Replaced <source> with <syntaxhighlight>) |
||
Line 7: | Line 7: | ||
# Attach to HUD and enjoy! | # Attach to HUD and enjoy! | ||
< | <syntaxhighlight lang="lsl2"> | ||
key owner; | key owner; | ||
integer gotTPperms; | integer gotTPperms; | ||
Line 234: | Line 234: | ||
} | } | ||
} | } | ||
</ | </syntaxhighlight> | ||
{{LSLC|Library|Teleport HUD}} | {{LSLC|Library|Teleport HUD}} |
Latest revision as of 11:41, 1 October 2022
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Gridwide Teleport HUD (works in no-script areas)
- Link 9 prims.
- Drop this script.
- Add up to 8 landmarks.
- 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;
}
}