server.player.scoreboard
Constants #
const max_lines = 15
max_lines is the number of lines the client renders under the title of a sidebar scoreboard. Anything past it is dropped by the client.
fn new #
fn new(name string) &Scoreboard
new returns an empty Scoreboard with the display name passed. Lines are added afterwards through write_line or set. Changing a Scoreboard after sending it does not update the board the player sees: it has to be sent again.
struct Scoreboard #
struct Scoreboard {
name string
mut:
lines []string
padding bool = true
descending bool
}
Scoreboard is the board drawn on the right side of a player's screen. Lines are held in display order, top to bottom, unless the board is set to sort descending.
fn (Scoreboard) name #
fn (board &Scoreboard) name() string
name returns the display name of the Scoreboard, drawn above its lines.
fn (Scoreboard) write_line #
fn (mut board Scoreboard) write_line(line string) !
write_line appends a line of text to the bottom of the Scoreboard. It fails once the board holds max_lines lines.
fn (Scoreboard) write #
fn (mut board Scoreboard) write(text string) !
write appends a block of text to the Scoreboard, splitting it into one line per newline. It fails once the board holds max_lines lines.
fn (Scoreboard) set #
fn (mut board Scoreboard) set(index int, line string) !
set replaces the line at index, padding the board with empty lines until that index exists. It fails if index falls outside the board.
fn (Scoreboard) remove #
fn (mut board Scoreboard) remove(index int) !
remove deletes the line at index, moving the lines under it up. It fails if index holds no line.
fn (Scoreboard) remove_padding #
fn (mut board Scoreboard) remove_padding()
remove_padding drops the space added to either side of every line, which is otherwise used to keep the board as wide as its title.
fn (Scoreboard) descending #
fn (board &Scoreboard) descending() bool
descending returns whether the Scoreboard is sorted bottom to top.
fn (Scoreboard) set_descending #
fn (mut board Scoreboard) set_descending()
set_descending sorts the Scoreboard bottom to top, reversing the order its lines are drawn in.
fn (Scoreboard) lines #
fn (board &Scoreboard) lines() []string
lines returns the lines of the Scoreboard as they should be drawn, with padding applied and the sort order honoured.