HUD widgets
A mode has 32 widgets, script_widget[0] to script_widget[31]. Each shows text and an optional bar, and every player has their own copy, so text, bars and visibility can differ from player to player. Widgets start hidden.
script_widget[0].set_text("Progress: %n", global.number[0])
script_widget[0].set_value_text("of %n", 30)
script_widget[0].set_meter_params(number, global.number[0], 30)
script_widget[0].set_visibility(all_players, true)
Reach's calls change the widget for every player:
set_text(text, …)- The widget's text.
%nputs in the next value as a whole number, up to three;%ba button, such asbutton.ability_3, which each player reads as their own key or controller button for it;%%is a percent sign. set_value_text(text, …)- More text after it, the same way;
""removes it. set_meter_params(number, value, maximum)- A bar filled to value out of maximum.
set_meter_params(none, 0, 0)removes it. A timer meter stops the script: read the timer into a number. set_visibility(all_players, true)- Shows the widget to everyone, or hides it with
false. Usecurrent_playerto show or hide it for one player.
Numbers are put in when the call runs, so call it again when they change. Text and value text, with the space between them, must fit 96 UTF-8 bytes with no control characters. A meter's maximum must be above 0, and meters don't print their values: add text for numbers. Widgets stay until changed; players who join mid-game and each split-screen player get them too.
Per-player text and placement
These calls take whose widget to change first: a player, such as current_player, or all_players. What all_players sets is also what players who join later start with.
set_text_for(who, text, …),set_value_text_for(who, text, …)- The text, for
whoonly. Same rules asset_text. set_meter_for(who, number, value, maximum)- The bar, for
whoonly;none, 0, 0removes it. reset(who)- Clears the widget: text, bar, placement and style. It's hidden afterwards.
set_position(who, x, y)- Places the widget on the script screen below. A widget without a position is a row laid out by
hud_layout. set_anchor(who, anchor)- Which point of the widget's box the position names:
top_left(the default),top,top_right,left,center,right,bottom_left,bottomorbottom_right. set_size(who, width, height)- The box's size.
0for a side fits it to the content; a width also wraps the text. set_alignment(who, center)- How the text sits in its box:
left,centerorright. set_color(who, r, g, b, a)- Text and bar color, each 0 to 255. White by default.
set_background(who, r, g, b, a)- Fills the box. None by default.
set_border(who, r, g, b, a)- Outlines the box. None by default.
set_font_size(who, size)- 8 to 72, in script-screen units. 16 by default.
set_weapon_icon(who, weapon or none)- A weapon's silhouette from Halo 3's own HUD before the widget's text, in the text's color and one and a half lines of it high; a widget with no text is the icon alone, sized by
set_font_size. The weapon by its name, such asbattle_rifle, or its tag path. For a placed widget. A weapon the installed Halo 3 has no silhouette for, another game's or a mod's own, shows none. set_clickable(who, true)- Lets a placed widget take clicks in its player's script menu.
The script screen is 1280 by 720 units, with 0, 0 at the top left. Each player's view, or their part of the screen in split screen, shows it scaled to fit and centered, so a layout keeps its proportions on every display. Positions must be on the screen and sizes no larger than it. Rows without a position use the widget's text color and font size; boxes, backgrounds, borders and clicks need a position.
on init: do
script_widget[4].set_position(all_players, 640, 20)
script_widget[4].set_anchor(all_players, top)
script_widget[4].set_size(all_players, 300, 0)
script_widget[4].set_alignment(all_players, center)
script_widget[4].set_background(all_players, 8, 16, 28, 170)
script_widget[4].set_font_size(all_players, 20)
end
for each player do
global.number[0] = current_player.get_kill_count()
script_widget[4].set_text_for(current_player, "%n kills", global.number[0])
script_widget[4].set_visibility(current_player, true)
end
Each player's own keys. %b in a widget's text names a button the way each player has it bound: set_text("Hold %b to launch", button.fire) reads “Hold Left mouse to launch” for one player and “Hold RT to launch” for another.
A call whose result breaks a limit, such as text that's too long, a position off the screen or a size or font size out of range, stops the script, as other errors while it runs do.
