Upset Baby Games

Upset Baby Games

Navigation

ubg_terminal_define_command

Syntax:

ubg_terminal_define_command(name, script, arg_count, force_type);
Argument name Type Description
name string name of command in terminal (case sensitive)
script int ID of script that the command should execute
arg_count int number of command arguments
force_type bool force datatype conversions (hints must be enabled)

Returns: (bool)

Description:

Defines a new command that can be used in terminal. Command definitions should consist of the command name, as a string, the script ID to execute, and the number of arguments to expect.

Commands can be overloaded as long as they have different argument counts. Trying to define two commands with the same name and argument count will throw a debugging message and refuse to add the new command.

When designing your execution script you should design it to accept two arguments. The first argument will be the name of the command being executed while the second argument will be an array consisting of every argument value typed by the user in the form of a string.

If hints are enabled and force_type is set to true, datatypes will be converted to match those specified in the hint (see ubg_terminal_define_hint). If this is not possible then 'undefined' will be used. For example, if you have a hint with the flag [room] then the room name will be converted to the room ID and passed as an int instead of the normal room name string. If the room doesn't exist then 'undefined' would be passed. For items such as variables and entries where the name is important they will still be passed as strings.

If hints are disabled then strings will always be passed (see ubg_terminal_set_showhints).

Examples:

ubg_terminal_define_command("game", game_command_scr, 1, true);