Skip to content

server.player.title

fn new #

fn new(text string) Title

new returns a Title showing the text passed, using the default fade and stay durations.

fn ticks #

fn ticks(d time.Duration) i32

ticks converts a duration to the tick count the client expects, rounding down but never below zero.

struct Title #

struct Title {
	text        string
	subtitle    string
	action_text string
	fade_in     time.Duration = tick
	fade_out    time.Duration = tick
	duration    time.Duration = 2 * time.second
}

Title is a piece of large text drawn in the middle of a player's screen, optionally with a subtitle under it and action bar text at the bottom. It is a value type: the with_* methods return a modified copy instead of mutating the receiver.

fn (Title) text #

fn (t Title) text() string

text returns the main text of the Title.

fn (Title) subtitle #

fn (t Title) subtitle() string

subtitle returns the text drawn under the main text, empty if none was set.

fn (Title) action_text #

fn (t Title) action_text() string

action_text returns the text drawn above the hotbar for as long as the Title is shown, empty if none was set.

fn (Title) duration #

fn (t Title) duration() time.Duration

duration returns how long the Title stays on screen, excluding the fades.

fn (Title) fade_in_duration #

fn (t Title) fade_in_duration() time.Duration

fade_in_duration returns how long the Title takes to fade in.

fn (Title) fade_out_duration #

fn (t Title) fade_out_duration() time.Duration

fade_out_duration returns how long the Title takes to fade out.

fn (Title) with_subtitle #

fn (t Title) with_subtitle(text string) Title

with_subtitle returns a copy of the Title with the subtitle passed.

fn (Title) with_action_text #

fn (t Title) with_action_text(text string) Title

with_action_text returns a copy of the Title with the action bar text passed.

fn (Title) with_duration #

fn (t Title) with_duration(d time.Duration) Title

with_duration returns a copy of the Title that stays on screen for d.

fn (Title) with_fade_in_duration #

fn (t Title) with_fade_in_duration(d time.Duration) Title

with_fade_in_duration returns a copy of the Title that fades in over d.

fn (Title) with_fade_out_duration #

fn (t Title) with_fade_out_duration(d time.Duration) Title

with_fade_out_duration returns a copy of the Title that fades out over d.