commands
INFO
Анықтаманың өзі ағылшын тілінде: ол WIT файлдарынан автоматты түрде жасалады.
Chat and console commands registered by mods. A registered command is routed to its mod for every allowed sender, before the built-in commands. Vanilla only treats / lines from moderators and admins as commands; mod commands work for any player unless min-role says otherwise.
Package blockheads:api@0.3.1 · Lua table bh.commands · WIT source
Uses: types.{api-error}, players.{role}, events.{command-sender}
Types
command-id type
txt
type command-id = u32;Identifies one registered command of the calling mod.
command-spec record
Describes a command.
| Field | Type | Description |
|---|---|---|
name | string | The name without /: [a-z0-9_-]{1,32}. Must not collide with built-in or other mods' commands. |
aliases | list<string> | Extra names, same rules as name. |
description | string | One line of help text. |
usage | string | Usage text shown when the handler returns handled = false, for example /home [name]. |
min-role | role | The lowest role allowed to run it from chat. |
console | bool | Whether the console may run it. |
command-outcome record
What a command handler returns.
| Field | Type | Description |
|---|---|---|
handled | bool | False shows the usage text to the sender. |
reply | list<string> | Lines sent back to the sender (chat for players, log for the console). |
Functions
register function
txt
register: func(spec: command-spec) -> result<command-id, api-error>;Registers a command; the host calls guest.run-command when it is used.
unregister function
txt
unregister: func(id: command-id) -> bool;Removes a command. Returns false if it did not exist.