Skip to content

Declaring Commands

Michael Dearman edited this page Apr 30, 2017 · 5 revisions

To use a command in the console, first it needs to be declared in the Commands code block inside the Create event for obj_console. You can use the console_add() script to declare new commands. This script takes 4 arguments:

Command [string]

The name of the command. This is what the user will enter into the console to execute the command.

Secure? [bool]

This sets whether the command can only be executed if the variable con_admin is set to true in console configuration.

Secure? [bool]

This sets whether the command can only be executed if the variable con_admin is set to true in the configuration settings for the console.

Arguments [string] [optional]

Here you can set the expected arguments for the command, if there are any. These should be split up with a comma. If the user does not include these arguments when trying to execute the command, the command is not executed.

Argument types [string] [optional]

Here you can set the expected data types for the arguments, if there are any. These should be split up with a comma. If the submitted arguments do not match the corresponding data types then the command is not executed. Should be either 'real' or 'string' type, but you can declare other types in User Defined Event 4.

Examples

console_add("game_end",false);
console_add("wmode",false,"toggle","bool");
console_add("score",true,"amount","real");
console_add("create_powerup",true,"x,y","real,real");

Once a command is declared, you can tell the console what to do when the command is entered. See: Executing Commands

External Links

Demo Video

Clone this wiki locally