Skip to content

players ​

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.

CaseDescription
playerA normal player.
moderatorListed in the server's moderator list.
adminListed in the server's admin list.
ownerThe 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).

MethodSignatureDescription
idfunc() -> stringThe player's stable id as sent by the game client (the vanilla playerID string).
aliasfunc() -> stringThe player's current alias (display name).
is-onlinefunc() -> boolTrue while the player is connected.
rolefunc() -> roleThe player's role on this server.
send-chatfunc(text: string) -> result<_, api-error>Sends a chat line only this player sees. Needs no permission.
posfunc() -> option<pos>(0.2) The tile of the player's blockhead; none when it is not in the world or the player left.
value-handlefunc() -> u64(0.2) The host handle that stands for this player inside values ({"$h": handle}, see types.value), for example in service arguments.
kickfunc(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 ​

txt
get: func(id: string) -> option<player>;

Looks up a connected player by id.

from-value-handle function ​

txt
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 ​

txt
find-by-alias: func(alias: string) -> option<player>;

Looks up a connected player by alias (case-insensitive).

online function ​

txt
online: func() -> list<player>;

All connected (approved) players, in join order.

broadcast function ​

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

Sends a chat line to every player, shown as a server message. Needs the players:chat permission.

Unofficial community project. Not affiliated with Majic Jungle Software or Noodlecake. No game files are included.