Skip to content

Examples

cobrapitz edited this page Oct 29, 2019 · 22 revisions

1. How To Add Custom Command

onready var console = $Console

func _ready():
    var printVariantRef = CommandRef.new(self, "my_variant_print", CommandRef.VARIANT)
    var printVariantCommand = ConsoleCommand.new('printVariant', printVariantRef, 'Custom print.')
    console.add_command(printVariantCommand )

    var printThreeRef = CommandRef.new(self, "my_three_print", 3)
    var printThreeCommand = ConsoleCommand.new('printThree', printThreeRef , 'Custom print.')
    console.add_command(printThreeCommand )

# VARIANT version (called with: /printVariant print this please !!!)
func my_variant_print(args : Array):
    for msg in args:
        print("This is my first message: %s" % msg) 

# 3-arguments version (called with: /printVariant print this please)
func my_three_print(arg1, arg2, arg3):
    print("your args: %s %s %s" % [arg1, arg2, arg3]) 

2. How To Write To The Console

console.write_channel("DebugChannel", "This is debug text(indented)", ConsoleFlags.Type.INDENT)
# or
console.write_line_channel(...)

console.write("test", flags)
# or
console.write_line(...)

3. Different Default Styles Of Messages

console.warn("This is a warning in yellow")
console.error("This is a error message in red")
console.success("This is a succes message in green")

# additional: [WARNING], [ERROR] or [SUCCESS] appended in log file

4. How to interact with channels

Clone this wiki locally