players
INFO
Анықтаманың өзі ағылшын тілінде: ол WIT файлдарынан автоматты түрде жасалады.
Connected players.
Package blockheads:api@0.3.1 · Lua table bh.players · WIT source
Uses: types.{api-error, pos}
Types
role enum
What a player may do on this server.
| Case | Description |
|---|---|
player | A normal player. |
moderator | Listed in the server's moderator list. |
admin | Listed in the server's admin list. |
owner | The server owner / console operator. |
player resource
A handle to one player, owned by the host. It stays valid while the player is connected; after they leave every method returns api-error::stale-handle (or a default value for infallible getters).
| Method | Signature | Description |
|---|---|---|
id | func() -> string | The player's stable id as sent by the game client (the vanilla playerID string). |
alias | func() -> string | The player's current alias (display name). |
is-online | func() -> bool | True while the player is connected. |
role | func() -> role | The player's role on this server. |
send-chat | func(text: string) -> result<_, api-error> | Sends a chat line only this player sees. Needs no permission. |
pos | func() -> option<pos> | (0.2) The tile of the player's blockhead; none when it is not in the world or the player left. |
value-handle | func() -> u64 | (0.2) The host handle that stands for this player inside values ({"$h": handle}, see types.value), for example in service arguments. |
kick | func(reason: string) -> result<_, api-error> | Disconnects the player with a reason text (shown to modded clients; vanilla clients see the generic kick message). Needs the players:kick permission. |
Lua: methods are called with :, for example player:id().
Functions
get function
get: func(id: string) -> option<player>;Looks up a connected player by id.
from-value-handle function
from-value-handle: func(handle: u64) -> option<player>;(0.2) The player behind a host handle from a value; none when the handle is stale (the player left).
find-by-alias function
find-by-alias: func(alias: string) -> option<player>;Looks up a connected player by alias (case-insensitive).
online function
online: func() -> list<player>;All connected (approved) players, in join order.
broadcast function
broadcast: func(text: string) -> result<_, api-error>;Sends a chat line to every player, shown as a server message. Needs the players:chat permission.