Skip to content

API Chat and Positions

Piggo41 edited this page Oct 12, 2026 · 8 revisions

Chat and positions

Lua API / Chat and positions

On this page

betamoon.chat:send(format, ...)

Displays a formatted local chat message. When a player is not yet available, up to 100 messages are queued and delivered when a player becomes available. The oldest message is discarded if the queue fills. Queued messages from an unloaded script are discarded.

betamoon.chat:send("Registered %i blocks", 3)

betamoon.chat:broadcast(format, ...)

Attempts to send a formatted message to all players through an accessible server. In singleplayer, falls back to local chat. If no server is accessible in multiplayer, reports a warning.

betamoon.chat:broadcast("Machine ready: %b", true)

BetaMoon chat formatting

The chat formatter supports these tokens.

Token Value
%i Integer.
%d Number, formatted numerically including fractional representation.
%b Boolean.
%s String.
%o Value converted to text.
%% Literal percent sign; consumes no argument.

Unsupported tokens, dangling %, wrong argument types, or extra/missing arguments produce a warning and suppress the message. Minecraft color sequences use §0–§9, §a–§f, and §r.

When a script name is available, it is prefixed to the message. This is the name from betamoon.mod.json for a packaged mod, or the script's name metadata for a loose script. Otherwise, the message is unprefixed.

betamoon.positions:integer(x, y, z)

Returns a position containing integer x, y, z. All three arguments are required.

local position = betamoon.positions:integer(12, 64, -4)

betamoon.positions:float(x, y, z)

Returns a position with numeric x/y/z stored at single-precision float accuracy. All arguments required; represents coordinates without moving anything.

local position = betamoon.positions:float(12.5, 64, -4.5)

Read the position through its x, y and z properties.

Examples: Utilities, chat.

Clone this wiki locally