Simple 3-Button HUD Example - SLUniverse Forums
 
Navigation » SLUniverse Forums > Development Discussion and Support > Scripting > Script Library » Simple 3-Button HUD Example


Script Library Post useful scripts here.

Reply
 
LinkBack Thread Tools Display Modes
Old 10-23-2009, 01:55 AM   #1 (permalink)
stored in the cloud

SLU Supporter
 
Kristian's Avatar
PHIL LINDEN SKULLF*CKED ME RIGHT HERE
 
Join Date: Jun 2007
Posts: 4,867
My Mood:
SL Join Date: 2/26/2005
Simple 3-Button HUD Example

First, you'll need a prim. I recommend the following dimensions:

Size
X: 0.15
Y: 0.05
Z: 0.01

Rotation
X: 0.00
Y: 270.00
Z: 270.00

Taper:
X: 0.66
Y: 0.00

The prim is, quite tiny, HUDs tend to be. Now, attach it. I recommend 'Center' as it's nice and easy to see, but put it where you're comfortable. Bottom and Top can be hard to see when you attach.Edit the prim, choose 'New Script' from the Content tab and put this in there:

Code:
// 3-Button HUD Shell
// by Kristian Ming 2009-10-22
// License: Public Domain (but a credit in your product documentation would be nice)

// We need to remap the faces to a more logical order...
integer return_button(integer f)
{
    if (f == 4) return 1;
    if (f == 0) return 2;
    if (f == 2) return 3;
    else return 0;
}

default
{
    touch_end(integer num_detected)
    // Not the most robust way of handling the touch event.
    // If this object was rezzed in world, it would be a problem
    // but HUDs can only be touched by the wearer
    {
        integer touchedFace = llDetectedTouchFace(num_detected); 
        llOwnerSay((string)return_button(touchedFace));
        // or you could assign it to a variable...
    }
}
There will be 3 distinct areas on the prim visible because the default texture will be rotated differently on the middle than the sides. Now click them! Leftmost will be 1, center 2, and right 3.

Not the most exciting HUD ever, but with a little work and research on <a href="http://wiki.secondlife.com/LSL_Portal">the LSL Portal</a> you'll be able to build more complex HUDs in no time.

Also, I'm making this and my other examples available in-world, time permitting. You can now visit 'Ming's Things' at http://slurl.com/secondlife/Stargazer/232/232/1501. I also have a blog.
Kristian is offline   Reply With Quote
1 User Said Yay!:
1 User Said Thanks:
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On