Docs » API reference » Hud

Hud

A small scoreboard by the player's watch, with a title and up to 12 lines. This page also covers boss bars and server tabs on the watch.

Besides menus, a plugin can show three things in a player's view. The player's game draws all three from what the plugin describes, and each is sent only when it changes, so they cost the server nothing per frame.

A HUD sits just below the player's watch face, where they glance at it as they would a watch. (Text fixed in front of the eyes is tiring in a headset.) It has a title and up to 12 lines, numbered 0 to 11. Each line is text (at most 24 letters) with a value at its right (at most 12) in one colour, and can have a bar under it (set_bar, a fraction from 0 to 1). A player sees one HUD at a time, so showing them another takes the first away.

A BossBar hangs above the player's line of sight and follows a moment behind as they turn. It is a title over a bar, for a boss's health or an event's countdown. A player sees two at most.

A server tab (Player set_wrist_tab) puts a Menu's first tab on the player's watch beside the watch's own pages. A player can have two. The tab shows the menu's first 24 elements, pressed as on the menu (the same MenuPressed, with tab 0), and changes to the menu show there at the end of the tick. Server tabs and HUDs do not show in the demo or in single-player.

Letters outside plain ASCII show as ?.

A handle to something in the game. Once that thing is gone, its calls fail with Gone. You get one from Hud.create(title); shown with hud.show(player).

Methods

MethodDescription
fn create(title: &str) -> Result<Hud>static Hud create(String title)An empty HUD (a title of at most 24 letters).
fn set_title(&self, title: &str) -> Result<()>void setTitle(String title)Changes its title.
fn set_line(&self, index: i64, text: &str, value: &str, colour: Colour) -> Result<()>void setLine(long index, String text, String value, Colour colour)Sets line index (0 to 11): its text, the value at its right (may be empty) and their colour. A bar it has stays.
fn set_bar(&self, index: i64, fraction: f64, colour: Colour) -> Result<()>void setBar(long index, double fraction, Colour colour)Gives line index a bar under its text, fraction (0 to 1) full.
fn clear_line(&self, index: i64) -> Result<()>void clearLine(long index)Empties line index, its bar too.
fn show(&self, player: Player) -> Result<()>void show(Player player)Shows it to a player, in place of any HUD they had.
fn hide(&self, player: Player) -> Result<()>void hide(Player player)Takes it away from a player.
fn remove(&self) -> Result<()>void remove()Takes it away from everyone and forgets it.

BossBar

A bar above the player's view: a title over a bar, at most two a player.

A handle to something in the game. Once that thing is gone, its calls fail with Gone.

MethodDescription
fn create(title: &str, colour: Colour) -> Result<BossBar>static BossBar create(String title, Colour colour)A full bar (a title of at most 32 letters).
fn set_title(&self, title: &str) -> Result<()>void setTitle(String title)Changes its title.
fn set_colour(&self, colour: Colour) -> Result<()>void setColour(Colour colour)Changes its bar's colour.
fn set_progress(&self, fraction: f64) -> Result<()>void setProgress(double fraction)How full it is, 0 to 1.
fn show(&self, player: Player) -> Result<()>void show(Player player)Shows it to a player (refused with Limit if they see two already).
fn hide(&self, player: Player) -> Result<()>void hide(Player player)Takes it away from a player.
fn remove(&self) -> Result<()>void remove()Takes it away from everyone and forgets it.