Skip to content

gdmp.console

Runs on: client. Since API level 120.

Your own commands in the GDMP console: every player opens it with F8 (the client log, a command line, the Draw FPS / Draw network overlays). Commands are for testing and for curious players – never for something a player needs to play.

Call What it does
register(name, description, handler) offers a command; handler(args, line) runs when it is typed and may return what the console shows (made a string, up to 4000 characters)
print(...values) warn(...values) error(...values) a line in the console (white / amber / red); values are joined with spaces
  • name: 1..24 of a-z 0-9 _ -, starting with a letter. GDMP’s own commands (help, clear, fps, net, ping, players, version, respawn, menu, copy, leave) cannot be taken. The same name again replaces the handler. At most 32 commands.
  • args: what follows the name, split on spaces; line: the same text, as typed.
  • The handler runs on the script’s thread like every other callback (its time counts against the script’s budget); a throw shows the error in the console and in the log.
gdmp.console.register('give', 'give yourself an item: give <item> [count]', (args) => {
const [item, count = '1'] = args;
if (!item) return 'give <item> [count]';
inventory.add(item, Number(count));
return `Gave you ${count} ${item}.`;
});

The declarations from the GDMP types (namespace GDMP), comments included:

interface Console {
/** `name`: 1..24 of `a-z 0-9 _ -`, starting with a letter. The handler may return what the console shows. */
register(name: string, description: string, handler: (args: string[], line: string) => unknown): void;
print(...values: unknown[]): void;
warn(...values: unknown[]): void;
error(...values: unknown[]): void;
}