Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
HUD Improved_HUD_positioner  

Improved_HUD_positioner

//
The HUD positioner is designed to set the HUD into a 'preferred' position whenever it get attached.
If the user moves it, and re-attaches it to the same spot, it ignores the hard-coded settings. It keeps a list of offsets from the top, bottom, left and right and moves the prim when it is first attached by that offset. Ity also forces the prim to face in a know direction, just in case it is accidentally rotated by the end-user.

If the HUD pops off-screen, wear another HUD, press Ctrl-3 to go into edit mode, click the other HUD, and use the scroll wheel to zoom out. You will see a line representing the edge of the 'normal' screen, and outside of it, hopefully, you will see the misplaced HUD.
You can then grab it and move it back on-screen.

Category: HUD
By : Ferd Frederix
Created: 2010-06-22 Edited: 2013-09-07
Worlds: Second Life

the Zip file

Download all files for Improved_HUD_positioner
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Improved_HUD_positioner_1.lsl

This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1 // This script was originally designed for a small HUD. You will probably need to edit the offsets that are in the script unless your HUD is also very small. The best way to do this is to wear the HUD, edit it, and look at the coordinates that appear in screen. These are offsets from the 'default' positions of the viewer. Move the prim to the correct position, and notice the X and Y and Z numbers change? You will need to change the Y and Z those numbers and put them in this scripts if you HUD is to go into another position.
2 //
3 // For example, if you attach something to the right side top or the right side bottom, the prim's center will normally be along the right edge. This script moves it to the left by trYoffset = 0.185 when at the top right, and brYoffset=0.125 when at the bottom right edge so that it can clear the little hump in some viewers. Another example is attaching to the very bottom, which is really bottom center. The script will move the prim vertically by BVerticalOffset = 0.080 to clear the nav bars, and leave the Y axis alone by adding to Y a 0.
4 // ______ _ ______ _ _
5 // | ___| | | | ___| | | (_)
6 // | |_ ___ _ __ __| | | |_ _ __ ___ __| | ___ _ __ ___ __
7 // | _/ _ \ '__/ _` | | _| '__/ _ \/ _` |/ _ \ '__| \ \/ /
8 // | || __/ | | (_| | | | | | | __/ (_| | __/ | | |> <
9 // \_| \___|_| \__,_| \_| |_| \___|\__,_|\___|_| |_/_/\_\
10 //
11 // fred@mitsi.com
12 // author Ferd Frederix
13 //
14
15 integer lasttarget;
16
17 default
18 {
19
20 attach( key id)
21 {
22
23 if(id)
24 {
25 integer target = llGetAttached();
26
27 vector position = llGetLocalPos();
28
29 if(target == lasttarget )
30 return;
31
32 lasttarget = target; // save the position we just set
33
34 float Y = 0.0;
35 float Z = 0.0;
36 float trYoffset = 0.185; // right edge
37 float brYoffset = 0.125; // right edge
38 float otherYoffset = 0.080; // move right from left edge
39 float VerticalOffset = 0.2; // move down for room for hover text
40 float CenterOffset = 0.7; // left and right center offset to left and right edge
41 float BVerticalOffset = 0.080; // Bottom Z.
42
43
44 if(target == ATTACH_HUD_CENTER_2)
45 {
46 Y = CenterOffset; Z = 0.0; // move to left edge
47 }
49 {
50 Y = trYoffset; Z = -VerticalOffset; // down for room for hovertext
51 }
53 {
54 Y = 0; Z = -VerticalOffset;
55 }
56 else if(target == ATTACH_HUD_TOP_LEFT)
57 {
58 Y = -otherYoffset; Z = -VerticalOffset;
59 }
60 else if(target == ATTACH_HUD_CENTER_1)
61 {
62 Y = -CenterOffset; Z = 0.0; // move to right edge
63 }
64 else if(target == ATTACH_HUD_BOTTOM_LEFT)
65 {
66 Y = -otherYoffset; Z = BVerticalOffset;
67 }
68 else if(target == ATTACH_HUD_BOTTOM)
69 {
70 Y = 0.0; Z = BVerticalOffset;
71 }
72 else if(target == ATTACH_HUD_BOTTOM_RIGHT)
73 {
74 Y = brYoffset; Z = BVerticalOffset ; // 2 x to miss buttons
75 }
76 else
77 {
78 llOwnerSay("You must attach this as a HUD");
79 return;
80
81 }
82
83 vector newtarget = <0.0,Y,Z>;
84 llSetPos(newtarget);
85
86 rotation myrot = llEuler2Rot( <0.0,90.0,270.0> * DEG_TO_RAD);
87 llSetLocalRot(myrot);
88
89
90 }
91 }
92
93
94 }

Back to the Best Free Tools in Second Life and OpenSim.