Console¶
server.console: the operator console on stdin,
started by listen() unless { console: false }.
Built-in commands: help, players, time [HH:MM], freeze,
unfreeze, skin <id> <model|random>, say <text>, kick <id> [reason],
tp <id> <x> <y> <z>, hp <id> <health> [armour], heal <id>.
command(name, usage, run)¶
Adds a command.
| Parameter | Type | Description |
|---|---|---|
name |
string |
What's typed first. |
usage |
string |
Shown by help. |
run |
function |
Gets the words after the name, and the rest of the line as typed. Throwing prints the error. |
server.console.command("give", "give <id> <amount>", ([id, amount]) => {
const player = server.player(Number(id));
if (!player) throw new Error(`no player ${id}`);
player.giveMoney(Number(amount));
});
server.console.command("announce", "announce <text>", (_args, rest) => {
server.broadcast(rest, Color.Yellow);
});
run(line)¶
Runs a line as if typed.