Coder Social home page Coder Social logo

4d49 / godot-console Goto Github PK

View Code? Open in Web Editor NEW
47.0 3.0 5.0 32 KB

Simple in-game console for Godot 4.2+

License: MIT License

GDScript 88.44% C# 11.56%
godot godot-engine godot-console game-console godot-plugin godot-addon gdscript godotengine

godot-console's Introduction

Godot-Console

Simple in-game console for Godot 4.x.

Features

  • Installed as plugin.
  • The Console is Singleton.
  • History of entered commands.
  • Autocomplete commands.
  • Static typing.

Installation:

  1. git clone this repository to the addons folder or download the latest releases.
  2. Enabled Godot Console in Plugins.
  3. Add ConsoleContainer node to the scene.
  4. Profit.

Usage:

Create console command:

# player.gd
func teleport(x: float, y: float) -> void:
	self.position = Vector2(x, y)

func _ready() -> void:
	Console.create_command("tp", self.teleport, "Teleport the player.")

Static typing:

With static typing, Console will try to cast arguments to a supported type.

# Arguments are float.
func teleport(x: float, y: float) -> void:
	self.position = Vector2(x, y)

Dynamic typing:

With dynamic typing, Console will NOT cast arguments to type, and arguments will be a String.

# Arguments are Strings.
func teleport(x, y):
	# Convert arguments to float.
	self.position = Vector2(x.to_float(), y.to_float())

Optional return string for print result to the console.

func add_money(value: int) -> String:
	self.money += value
	# Prints: Player money:42
	return "Player money:%d" % money

C# Bindings:

You can add 'addons/godot-console/scripts/ConsoleMono.cs' to Autoloads after 'Console'.

public partial class Test : Node
{
	private void Foo(string a, string b)
	{
		ConsoleMono.Print(a + " " + b);
	}

	public override void _Ready()
	{
		ConsoleMono.CreateCommand("foo", Foo); // You can pass method directly as delegate.
		ConsoleMono.CreateCommand("foo2", this, MethodName.Foo); // Or you can pass target object and method name.
	}
}

License

Copyright (c) 2020-2024 Mansur Isaev and contributors

Unless otherwise specified, files in this repository are licensed under the MIT license. See LICENSE.md for more information.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.