Don't click here unless you want to be banned.

LSL Wiki : HeadsUpDisplay

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl338.us.archive.org

Heads-Up Display


Introduced in SL 1.7, the 8 heads-up display (HUD for short) attachment slots are visible only to the user to which they're attached. They're intended to allow scripters to create user interface elements, such as speedometers, game buttons, health readouts, etc.

Despite being invisible to other users, HUD attachments are just like any other attachment: they can be scripted, can automatically attach to an avatar, and can communicate via chat and other methods.

Values for llGetAttached and llAttachToAvatar:
Value Position
31 HUD Center 2
32 HUD Top Right
33 HUD Top
34 HUD Top Left
35 HUD Center
36 HUD Bottom Left
37 HUD Bottom
38 HUD Bottom Right

HUD attachments can be moved around the user's screen:

llGetLocalPos can be used to get the HUD attachment's current position. (Notice that this isn't the same as llGetPos which seems to tell the avatar coordinates instead of the HUD attachment coordinates.)
llSetPos sets position.

How HUD Positioning Coordinates Work


(Being familiar with vectors will help.)

Each HUD attachment point has its own origin point, <0,0,0>. Only the .y and .z components are used for positioning, so an example position might be <0.0, 0.2, -0.8>, where 0.2 is the value of the horizontal axis and -0.8 the value of the vertical axis. The .x component is used to determine which HUD overprints when two HUDs overlap. More negative .x HUDs will render on top of less negative ones.

Rather than the more traditional coordinate layout, where numbers get bigger the farther up and right they go on the grid, the numbers on the horizontal axis of HUD attachment grid get larger as they move towards the left side of the screen. (Fortunately, the vertical axis is normal -- larger numbers are higher on the screen, smaller numbers are lower.)

The grid the HUD uses is square, not scaled relative to the size of the SL window, so setting an attachment in the HUD bottom right slot to a position of <0.0, 1.0, 1.0> will not put it in the upper left corner. However, it will put it at the top of the screen -- the HUD grid scales with the height of the SL window.

HUD attachments can still be positioned vertically without any trouble, as long as it is known where they're attached, but horizontally is another story. Because each attachment point is relative to window size, it'll end up vertically where desired.

This means that you can use the upper or bottom corner attachment slots to position an attachment in the corner above or below it, and be certain that it'll end up there on everyone's computer.

However, an attachment can't be positioned to one of the corner slots to a position on the opposite side of the screen with any reliability, as the dimensions of the SL window will change from computer to computer. (Note: there is no way to determine a user's window dimensions or aspect ratio.)

Note: It is now possible to find screen width using the new llDetectedTouch* functions. The script below will give the width of the screen in meters by touching anywhere on the visible face, given that the prim is a box with zero rotation and attached at one of the corner HUD attachment points.

default
{
    touch_start(integer total_number)
    {
        vector scale = llGetScale();
        vector off_point = llGetLocalPos();
        vector face_pos = llDetectedTouchST(0);
        vector screen_pos = llDetectedTouchPos(0);
        
        float screen_width = ((face_pos.x-.5)*scale.y-off_point.y+screen_pos.y)*2;
        
        llOwnerSay((string)screen_width);
    }
}

The range of possible coordinates for HUD attachments is greater than <0.0, -1.0, -1.0> to <0.0, 1.0, 1.0>, but the actual position llSetPos will move the attachment to appears to be unpredictable when the origin point of the attachment passes offscreen.

HUD Quirks and Workarounds


"Solid" HUD attachments
One frequent complaint about the HUD system is that even when fully transparent, HUD attachments still don't allow clicking "through" them to the world behind. One workaround for this is to use llSetPos to reposition the attachment offscreen when necessary for it to be "invisible". Note that in SL 13.0.8 (not sure which version this started in) you can use the mouse-wheel to shrink the HUD layer to the center of the screen (making the majority of the screen useful again).

Particles appear at <0,0,0>
When using llParticleSystem in a HUD attachment, particles will appear to come from <0,0,0> in the sim, not the HUD attachment. There is no workaround. Don't use particles in HUDs.

Q: Is it possible to trigger a sound in a HUD attachment that only the owner hears?
A: Yes. llPlaySound in a HUD attachment will only be heard by the owner.
A: You can also use llTriggerSoundLimited using llGetPos as both vectors which would give that headphones effect. (Incase you want to use a triggersound function) -- DarwinRecreant


Attachment | User Interface | AgentAndAvatar | Jasa SEO Jasa SEO Murah Sepatu Online Toko Sepatu Online Sepatu Sepatu Murah Sepatu Safety Sepatu Futsal Cheapes Hostgator Coupon Link Booking Televisori offerte Notebook Offerte Berita Terkini Internet Marketer Muda Internet Marketer Indonesia Portatile Apple RDAnet Lorks Karikatur Bisnis Modal Kecil Bisnis UKM Berita Terbaru Iklan Baris Jasa SEO Jasa SEO Murah SEO Indonesia Konsultan SEO SEO Belajar SEO Kursus SEO Kursus SEO Murah Jam Tangan Casio Jam Tangan Casio Jam Tangan Murah Jam Tangan Grosir Baju Terbaru Grosir Baju Baju Terbaru Grosir Baju Murah Bisnis Online Belajar SEO Kerupuk Kerupuk kulit Social Bookmark Dofollow Social Bookmark Kumpulan Puisi Kirim Puisi bola hantu Penumbuh Rambut Penumbuh Rambut timbangan WBC Wonogiri Jasa SEO Murah Jasa SEO Jam Tangan Murah
Comments [Hide comments/form]
Are these objects viewable only to the player, or something akin to the llDialog box? Any know yet?
-- AfirZ (2005-10-13 03:04:31)
Objects attached to the HUD attach points cannot be seen by other players.
-- BlindWanderer (2005-10-14 12:52:33)
HUD attachments don't allow the camera to be focused/zoomed/panned "through" them, making them essentially useless and always in the way--annoying!
-- EepQuirk (2005-11-04 03:45:08)
I'd disagree. HUD attachments are meant to be used for things like an animation overrider that maintains a clickable section on your screen to allow for controlling the AO. No more llDialogs, for example, with HUD attachments.
-- WolfWings (2005-11-04 04:44:21)
As of 1.7.2, HUD attachments support llSetText.
-- ZodiakosAbsolute (2005-11-09 11:54:56)
Is there a way to check if the HUD is visible (menu/view/ show HUD attachments not the Lsl Functions llSetPos/llGetPos) ?
-- MartinMorris (2006-08-29 02:41:17)
as far as particles go, if a HUD can manipulate the loc of a child prim, it might be possible to use the child prim to emit particles.
-- ip72-200-123-202.tc.ph.cox.net (2007-06-10 13:44:46)
Attach a comment to this page: