HUD

From ActiveWiki
Jump to navigation Jump to search

Heads Up Display

The HUD is a new feature starting with 4.1 Browser build 963. It allows programmers to display images or text within the 3D viewport.

The goal of the HUD (short for Heads Up Display) is to provide a dynamic interface within the 3d window which can be controlled by a bot. A HUD is made up of one or more elements, which are sent to a user from a bot. Each element has a specific appearance, position, size, and has a unique id. Optionally, HUD elements may also accept mouse clicks, which will send a message to any global bot when the element is clicked by the user.

Note that a bot must have caretaker rights in a world in order to send HUD elements to users. Also note that any number of bots can provide HUD elements to the user, so care should be take to make sure they do not interfere with each other. For example, if two bots both place elements in the upper-right corner of the display, then the elements will overlap and may interfere with each other.

Note also that elements are not destroyed when the bot leaves the world. If the bot places the word "Hello" in the center of the user's screen and then exits, then the user will be stuck with it until they leave the world or another bot calls aw_hud_destroy or aw_hud_clear to have the user to remove the element. Care should be taken to avoid leaving "orphaned" elements on the viewport.

The bot starts by calling aw_hud_create for one or more users. This will cause the HUD element to be rendered on the users screen. If the HUD element is clickable, then the bot will get an AW_EVENT_HUD_CLICK event whenever a user clicks the HUD element. The bot will recieve the id of the element, as well as the position of the click relative to the upper-left corner of the element. The bot can later call aw_hud_destroy or aw_hud_clear or remove the elements when it is done interacting with the user.

A user's HUD is cleared whenever they leave the world. If the user teleports to another world and returns then the HUD element will be gone and will need to be re-created by the bot.

See also

External Links