samgreen / godot-console

In-game console for Godot 3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Godot Console

In-game console for Godot, easily extensible with new commands.

Quake-style console for Godot

Features

  • Writing to console using write and writeLine method. You can use BB codes. (Also printed to engine output)

    Console.writeLine('Hello world!')

  • Auto-completion on TAB (complete command), Enter (complete and execute).

  • History (by default using with actions ui_up and ui_down)

  • Custom types (Filter, IntRange, FloatRange, and more...)

  • Logging

Installation

  1. Clone or download this repository to your project folder.
  2. Add src/Console.tscn to godot autoload as Console.
  3. Add new actions to Input Map: console_toggle, ui_up, ui_down

Example

Registering command:

func _ready():
	Console.register('sayHello', { # Command name

		'description': 'Prints hello world',

		'args': [ARGUMENT, ...],
			# This argument is obsolete if
			# target function doesn't
			# take any arguments

			# [Object, variable/method name]
		'target': [self, 'print_hello']
			# Target to bind command.
			# Providing name is obsolete
			# if command name is same.

	})

func print_hello():
	Console.writeLine('Hello world!')

ARGUMENT should look like this:

  • ['arg_name', ARG_TYPE]
  • 'arg_name' — In this situation type will be set to Any
  • ARG_TYPE

More information about ARG_TYPE you can find in this readme.

You can find more examples in src/BaseCommands.gd


Great thanks to @Krakean and @DmitriySalnikov for the motivation to keep improving the original console by @Calinou.

Take a look at their implementations.

License

Licensed under the MIT license, see LICENSE.md for more information.

About

In-game console for Godot 3

License:MIT License


Languages

Language:GDScript 100.0%