Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: HUD, Hovering Text, and Dialog Example

Clayton Cinquetti
Registered User
Join date: 17 May 2005
Posts: 38
12-20-2006 21:52
Below are instructions on how to make a HUD that has text displayed on it. When you click on the HUD a dialog box pops up with a number of options displayed. When you click on one of the options the HUD text changes.

1. Create two thin blocks one on top of eachother. Texture the top box with a color that red text would stand out on. Cover the bottom box with a transparent color. Link the two boxes together. Make sure the bottom box is the last box linked.
2. Add the script below to the bottom box.
3. Once the script is added to the bottom box you should see the words "Click HUD for dialog of options" hovering over the bottom box. Position the camera so you're looking directly at the front face of the top box, and position the bottom box so that the hovering text is positioned in front of the top box.
4. Add the linked objects to you HUD in the center location. If you want the HUD to ultimately be in the upper left corner, for example, reposition the HUD to the lower right from the center location so that when you put it in the upper left it won't be off the screen.
5. When you click on the HUD the dialog box should pop up. When you select an option from the dialog box the HUD floating text should change.

If you need more detailed instructions, I go into a little more depth on my blog www.secondlifehowto.com. I also have screen shots if the above written descriptions are unclear.

PHP Code:
CODE

// when HUD touched, present a dialog with four color choices

integer CHANNEL = 42; // dialog channel
list MENU_MAIN = ["Sit", "Stand", "Fly", "Cheat", "Options..."]; // the main menu
list MENU_OPTIONS = ["Cherry", "Blueberry", "Vinegar", "Slime", "Chips", "Salad", "...Back"]; // a submenu

default {
state_entry()
{
llListen(CHANNEL, "", NULL_KEY, ""); // listen for dialog answers (from multiple users)

// Set text to display in bright red
llSetText("Click HUD for dialog of options", <1,0,0>, 1.0);

}

touch_start(integer total_number)
{
llDialog(llDetectedKey(0), "What do you want to do?", MENU_MAIN, CHANNEL); // present dialog on click
}


listen(integer channel, string name, key id, string message)
{
string response_string;

if (llListFindList(MENU_MAIN + MENU_OPTIONS, [message]) != -1) // verify dialog choice
{
//llSay(0, name + " picked the option '" + message + "'."); // output the answer
response_string = name + " picked the option '" + message + "'.";
if (message == "Options...")
llDialog(id, "Pick an option!", MENU_OPTIONS, CHANNEL); // present submenu on request
else if (message == "...Back")
llDialog(id, "What do you want to do?", MENU_MAIN, CHANNEL); // present main menu on request to go back
// here you have the name and key of the user and can easily verify if they have the permission to use that option or not
else if (message == "Sit")
{
//llSay(0, "This is where stuff would happen if this wasn't just an example");
response_string = "This is where stuff would happen if this wasn't just an example\n";
response_string = response_string + "Click HUD for dialog of options";
}
}
else
{
//llSay(0, name + " picked invalid option '" + llToLower(message) + "'."); // not a valid dialog choice
response_string = name + " picked invalid option '" + llToLower(message) + "'.\n";
response_string = response_string + "Click HUD for dialog of options";
}

// Set text to display in bright red
llSetText(response_string, <1,0,0>, 1.0);

}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
12-24-2006 20:50
/15/d3/156118/1.html
_____________________
i've got nothing. ;)