Skip to content

ui ​

INFO

Başvuru metni WIT dosyalarından otomatik üretildiği için İngilizce.

Mod UI on the client (IG-HUD, IG-ModUI): HUD widgets, toasts, notices and dialogs. Mods send data, the loader draws it with its own kit: mods cannot restyle it, place widgets freely or take focus away from the game. Needs no permission, and players can hide any mod's widgets. Server-side hosts and clients without a UI return api-error::unsupported. Added in 0.3. Dialog results arrive as a custom event named <mod-id>:ui-action (subscribe with events.subscribe-custom), delivered to the mod that opened the dialog only; the payload is a types.value map {"dialog": u32, "button": u32, "text": string or null} (button counts from 0, null text when the dialog has no field). Closing the dialog from the loader side (back, the game leaving the world) is button 4294967295.

Package blockheads:api@0.3.1 · Lua table bh.ui · WIT source

Uses: types.{api-error}

Types ​

slot enum ​

Where a HUD widget goes. The loader stacks the widgets of a slot, keeps the game's own HUD and the screen cutout clear and hides what does not fit.

CaseDescription
top-leftUnder the game's HUD, top left.
top-rightTop right.

widget-kind enum ​

What a HUD widget looks like.

CaseDescription
textOne line of text (with an optional icon).
counterAn icon and a number: text holds the number.
panelA small panel: title and up to four lines of text (split on newlines).

widget record ​

One HUD widget. Updating a widget with the same id replaces it.

FieldTypeDescription
slotslot
kindwidget-kind
iconoption<string>A kit icon name: coin, heart, info, warn, check, cross, bell or clock (more are added over time). Unknown names draw no icon.
titleoption<string>The panel title (ignored by the other kinds).
textstringThe text, at most 256 bytes.

notice-level enum ​

How a notice looks.

CaseDescription
info
warning
success
error

button-kind enum ​

How a dialog button looks.

CaseDescription
primary
secondary
danger

dialog-button record ​

One dialog button.

FieldTypeDescription
labelstringAt most 24 bytes.
kindbutton-kind

field record ​

The single text field of a dialog.

FieldTypeDescription
placeholderstring
initialstring
max-lengthu32At most 200.

dialog record ​

A dialog: title, text, an optional field and one to three buttons.

FieldTypeDescription
titlestringAt most 64 bytes.
textstringAt most 512 bytes.
fieldoption<field>
buttonslist<dialog-button>

Functions ​

set-widget function ​

txt
set-widget: func(id: string, widget: widget) -> result<_, api-error>;

Shows or updates a widget. id is 1 to 32 characters of a-z0-9_.-, unique within the mod; a mod has up to 16 widgets.

remove-widget function ​

txt
remove-widget: func(id: string) -> bool;

Removes a widget. Returns false if it did not exist.

toast function ​

txt
toast: func(text: string) -> result<_, api-error>;

A short message that stacks bottom right (at most three visible, about four seconds each). text is at most 200 bytes.

notice function ​

txt
notice: func(text: string, level: notice-level) -> result<_, api-error>;

A notice in the top centre, one at a time (a new one replaces the last). text is at most 200 bytes.

show-dialog function ​

txt
show-dialog: func(dialog: dialog) -> result<u32, api-error>;

Opens a dialog (one at a time per mod) and returns its id. The answer comes as a <mod-id>:ui-action event.

close-dialog function ​

txt
close-dialog: func(id: u32) -> bool;

Closes a dialog of the mod without an answer. Returns false if it was not open.

Resmî olmayan topluluk projesi. Majic Jungle Software veya Noodlecake ile bağlantısı yoktur. Oyun dosyası içermez.