This addon includes a custom node which can represent a console and textchat. You can print messages in game to the console to help you debug or register commands for debugging.
Install via Godot AssetLib and enable plugin in project settings.
Add the "ConsoleAndTextchat" node to your scene tree. Adjust positioning and size in the scene.
To print messages use the node.print_message(text: String)
method. Insert the string you want to be printed.
You can customize the message using different colors and text formatting or add a timestamp. To see how you
customize your message look in the demo scene and method documentation.
To create commands use the node.register_command(command_name: String, function: Callable, arguments: bool = true)
method.
Enter a name and the method/function to be called upon entering the command into the console. The arguments
argument describes
wether the callback method has arguments attached.
Calling commands through the console is simple. Every command starts with "/" followed by the command itself.
Additionally every argument is entered with a space inbetween: "/say_hello_to player_one playert_wo".
The entered arguments are given to the method that was registered to a given comment as an array of Strings ["player_one", "player_two"]
.
-
help
Displays all registered commands. -
toggle_console
Used to toggle the console. The console can also be toggled using the "K" key. -
clear
Used to clear the console of all text.
-
void
print_message(text: String)
Main method to print a message to the console/textchat. Thetext
string can be customized using the different text formatting methods. Text formatting can be achieved with bbcode. -
void
register_command(command_name: String, function: Callable, arguments: bool = true)
Register a command to be used through the console. Thecommand_name
is written into the console. Thefunction
is a Callable that is called when thecommand_name
is entered into the console. If thefunction
has no arguments setarguments
tofalse
. -
void
delete_command(command_name: String)
Deletes a registered command. -
void
clear_console()
Deletes all entered Text. -
String
timestamp()
Return the current system time in the form [h:min]. -
String
col(color, text: String)
To color atext
insertcolor
as aColor
type or as a string that represents a html/hex color code in the form #xxxxxx. -
String
bold(text: String)
To print atext
in bold. -
String
italic(text: String)
To print atext
in italic. -
String
underline(text: String)
To print a underlinedtext
. -
String
crossed(text: String)
To print a crossedtext
.