Console and Textchat Node
by KeilainMan
Console and Textchat Addon
Purpose
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.
Features
[x] Usable as textchat
[x] Usable as a simple console for your game
[x] Simple debugging through custom cheatcodes
[x] Text History
[x] Textstyling through code
[x] Customization settings
Installation
Install via Godot AssetLib and enable plugin in project settings.
See Installing a plugin from the Godot docs for further assistance.
How to use
Add the "ConsoleAndTextchat" node to your scene tree. Adjust positioning and size in the scene.
Printing messages to the console
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 and demo2 scenes for examples.
Commands
Creating commands
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
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"]
.
Build in commands
-
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.
Controls
The console supports navigating command history using Shift + Arrow keys.
If anyone knows how to simplify this to just the Arrow key, notify me. Currently it clashes with build in LineEdit
controls
-
Shift + Up Arrow
Navigate to the previous command. -
Shift + Down Arrow
Navigate to the next command.
Others:
-
k
Toggle console window. -
Enter
Grab focus of thetext_input_line
to inserttext
Export Properties
-
Vector2
Minimum Size
Describes the minimum_size of the console window. -
Theme
Text Input Line Default Theme
Add a theme to style the console window. -
bool
Override Theme Colors
true
; Iftrue
History Preview Color
will override the colors set in the theme. -
Color
History Preview Color
Color Salmon
; A color to highlight thetext
in history mode. -
bool
Disable Text Input Line
false
; Disables thetext_input_line
. -
bool
Disable Key Enter Focus
false
; Disables the control to grab focus onEnter
pressed.
Methods
-
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 enteredtext
. -
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
.
Download
Support
If you need help or have questions about this plugin, please contact the author.
Contact Author