Console Class
This set of functions controls console-related parameters.
Console Class
Members
void setWarningColor (vec4 color)
Sets a color for warning messages in the console.Arguments
- vec4 color - Four-component vector specifying the color in the RGBA format.
int isCommand (string name)
Returns a value indicating if a command with a given name exists.Arguments
- string name - Command name.
Return value
1 if the command exists; otherwise, 0.void setErrorColor (vec4 color)
Sets a color for error messages in the console.Arguments
- vec4 color - Four-component vector specifying the color in the RGBA format.
void setInt (string name, int value)
Sets an integer value for a given variable.Arguments
- string name - Variable name.
- int value - Value of the variable.
int addCommand (string name, string desc, CallbackBase * callback)
Adds a custom console command bound to a given script function. The command can have up to 6 arguments, which will be passed to the script function.
The example shows how to add a custom console command with 2 arguments:
namespace Test {
// A script function to be performed for no arguments input.
void my_command_callback() {
log.message("my_command callback\n");
}
// A script function to be performed for one argument input.
void my_command_callback(string arg_0) {
log.message("my_command callback arg_0 :%s\n",arg_0);
}
// A script function to be performed for two arguments input.
void my_command_callback(string arg_0,string arg_1) {
log.message("my_command callback arg_0:%s, arg_1:%s\n",arg_0,arg_1);
}
}
/*
*/
int init() {
engine.console.addCommand("my_command","my_command description","Test::my_command_callback");
return 1;
}
/*
*/
int shutdown() {
engine.console.removeCommand("my_command");
return 1;
}
// Input value: my_command
my_command callback
// Input value: my_command 1
my_command callback arg_0 :1
// Input value: my_command 1 2
my_command callback arg_0 :1 arg_1 :1
Arguments
- string name - Name of the new console command.
- string desc - Short description to be displayed in the console.
- CallbackBase * callback - Name of the target script function.
Return value
Returns 1 if the custom command is added successfully; otherwise, 0.void setTextColor (vec4 color)
Sets a common font color for the console.Arguments
- vec4 color - Four-component vector specifying the color in the RGBA format.
string getString (string name)
Returns a string value of a given variable.Arguments
- string name - Variable name.
Return value
Value of the variable.void setMessageColor (vec4 color)
Sets a color for ordinary messages in the console.Arguments
- vec4 color - Four-component vector specifying the color in the RGBA format.
int getInt (string name)
Returns an integer value of a given variable.Arguments
- string name - Variable name.
Return value
Value of the variable.int getLock ()
Checks if the console is disabled.Return value
1 if the console is disabled; otherwise, 0.int isVariable (string name)
Returns a value indicating if a variable with a given name exists.Arguments
- string name - Variable name.
Return value
1 if the variable exists; otherwise, 0.void setBackgroundColor (vec4 color)
Sets a background color for the console.Arguments
- vec4 color - Four-component vector specifying the color in the RGBA format.
float getFloat (string name)
Returns a float value of a given variable.Arguments
- string name - Variable name.
Return value
Value of the variable.void setFloat (string name, float value)
Sets a float value for a given variable.Arguments
- string name - Variable name.
- float value - Value of the variable.
void setActivity (int activity)
Open or close the console. By default the console is closed.Arguments
- int activity - Positive integer to make the console active (opened); otherwise, 0.
void setString (string name, string value)
Sets a string value for a given variable.Arguments
- string name - Variable name.
- string value - Value of the variable.
int getActivity ()
Returns a state of the console.Return value
1 if the console is active (opened); otherwise, 0.void setLock (int lock)
Disables or enables the console. By default the console is enabled.Arguments
- int lock - Positive integer to disable the console; otherwise, 0.
void setPrompt (string str)
Updates the console prompt. The default prompt is Unigine~#.Arguments
- string str - New console prompt.
Last update: 2017-07-03
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)