quentincaffeino / godot-console Goto Github PK
View Code? Open in Web Editor NEWIn-game console for Godot 3.
License: MIT License
In-game console for Godot 3.
License: MIT License
As a lot of the time commands can autocomplete to different commands it's been common in Bash and other linux command lines to have tab autocomplete to the next option.
if you have commands 'hef', 'hel' and 'help' then h- displays hef as it's the shortest and closest match. again (after completed to hef) autocompletes to hel then one last time autocompletes to help.
This can be done by holding the original typed string in a buffer (variable or such) and then iterating over the original list of autocompleted options. Typing again would clear this buffer and option list.
Thanks,
Michael Brune
I get the error Invalid operands 'String' and 'Nil' in operator '+'.
when I try writing, for example, somestring'
or even just ''
in the console. It doesn't happen for a singular standalone single/double quote '
. It also doesn't give an error for 3+ quotes '''
.
It's also worth noting that if there is more than one quote after the string ex. hello''
the console will say Command `ello'` not found.
culling the first char in the string, which may or may not be related.
run the project, write 'foo' in the console then press TAB twice
following error occurs
Invalid call. Nonexistent function 'getValueIterator' in base 'Reference (CommandCollection.gd)'.
try same steps but with 'h' written into the console
there is a problem if there are multiple autocomplete options
MRP: https://www.dropbox.com/s/hvnc7vlwp0igle7/ConsoleAutocompleteError.7z?dl=1
I'm getting this error when trying to call my custom command:
E 0:00:04.854 callv: Error calling method from 'callv': 'Node(CustomCommands.gd)::kill': Method expected 1 arguments, but called with 0..
<C++ Error> Method failed. Returning: Variant()
<C++ Source> core/object.cpp:830 @ callv()
<Stack Trace> Callback.gd:55 @ call()
Command.gd:72 @ execute()
ConsoleLine.gd:129 @ execute()
This is how I'm registering my command:
func _ready() -> void:
Console.add_command("kill", self, "kill")\
.set_description("Kills the player instantly by dealing 100 points of damage. Takes in a player username as an argument. If no username is given, kills the player that ran the command.")\
.add_argument('victim', TYPE_STRING)\
.register()
And this is the function that it calls:
func kill(victim):
$"/root/GameController".get_node(str(victim)).take_damage(100, "shotgun", Global.username)
Both of these are in an autoloaded script and I followed the format from the docs.
So the problem with just the key code KEY_QUOTELEFT is that on some keyboards it refers to a not that rare used letter. That's also the reason why VSCode's default key to open the console is Ctrl + KEY_QUOTELEFT.
I would ask for doing the same here, so people with a different keyboard layout won't be forced to adjust the settings.
For example, I type 'comm', press ENTER. It executes the command 'commands'.
If I type 'comm' again, press ENTER, I get :
[ERROR] CommandGroup: _getCommand: Unable to provide with proper autocomplete.
This goes for any command. Does a first ENTER will work, then any subsequent try gives the error above.
Using Godot 3.1.2
So yeah, the idea is to make the UI a separate entity to be able to swap them and also to give option for user to use multiple instances of the console or use console with no ui at all (for eg. to create a cli app).
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
.github/workflows/automatic_release.yml
actions/checkout v3
addons/@quentincaffeino/godot-callback/package.json
addons/quentincaffeino/console/package.json
gut 7.3.0
package.json
gut 7.3.0
demo-csharp/Demo-csharp.csproj
Godot.NET.Sdk 3.3.0
Using a Console.theme file, that the user is able to edit with ease, would enable every user to adjust the style of the console to fit their game's style. Also, things like increasing the console's font size on bigger screens would get possible. I think it even will save a bit of memory.
Would be a great and relatively easy to do upgrade :)
As far as I can tell, there's no way to make an argument optional. This would be really nice, and I imagine not too complicated to implement, but I've tried and I don't understand the code well enough
Greetings,
Are there any plans to update for Godot 4?
Kind regards
Hi,
You have these commands:
sayhello
seeversion
So if you type S, a small HBoxContainer will show all commands with S, and if you type TAB, the command line will show "sayhello", and if you type TAB a second time, the command line will show "seeversion.
Otherwise the chat will be crowded with all commands. (If you use it also as chat)
Thanks,
Gamemap
It's possible this is my problem, but I am receiving this error in Console.gd. Reviewing it, the code indent blocks look messed up, they are two spaces instead of the traditional four. I don't think that is the problem though, it looks like some tabs are missing? At any rate, this causes the code to error out. Any suggestions?
Right now, this plugin uses camelCase for method names, whereas snake_case is typically used in GDScript. Constants also use PascalCase, but the GDScript style guide recommends using UPPER_SNAKE_CASE for those.
It would be good to modify scripts to better match the core Godot API and other established plugins out there. This way, users can use the plugin's methods without introducing style clashes in their existing scripts.
Required for #40.
Something like Console.reset_to_default()
to remove all commands besides the default ones.
My player character is creating console commands, but when I switch levels or go to the menu, all the commands break because they can't find a reference. Also, in the menu, commands relating to the player or gameplay shouldn't work anyway, and it's a lot to remember to remove each command manually when the scene changes, and adding a call for each new command I create.
Tried installing the project, but I'm getting an error in Argument.gd->build.
I've added Console.tscn as an autoloaded singleton, but this is still happening.
project.godot included in the zip.
Ver: Godot 3.1 stable
Godot version: v3.2.3.stable.mono.official
godot-console version: 3.1.3
OS/device: macOS 10.14.6, MacBook Pro (2017)
Issue description:
When exiting a project with godot-console enabled, there are many ObjectDB instance leaks.
Steps to reproduce:
Minimal reproduction project and log output:
console_test.zip
log_output.txt
Hi,
you have build a good addon, but sadly I don't understand how to add commands.
Please tell me how to do that.
Thanks,
Gamemap
when copying the project and testing it this shows up
Invalid call. Nonexistent function 'register' in base 'Nil'
im new to Godot so i dont know what im doing wrong
The documentation is a bit lacking. I'm not really away of everything this add-on can do, and I often have to dig into the source code to figure out how to do something. I'd be willing to help in this endeavor, if you can tell me how I can.
While trying to get an error message to show with red color in the console, I noticed that not even the basic console messages have their yellow color (This is in 3.5.stable):
I quickly tested the console in 3.4.4.stable and yes the colors are back.
So, it seems like 3.5.stable breaks something with bbcode. Probably not just the colors.
Tried it multiple times but no luck, would appreciate any help with that.
More info: #48 (comment)
my animated sprit does not working
when i press up the player jump and it play the first frame and ignore the rest
there is for frames but just the first who play
Right now, the console is automatically autoloaded and works in every scenes of the project.
What if I don't want this behavior ?
I might want to use the console only in certain scenes : for example, I might want it in the actual game for quick debugging, but not in the actual menu.
I suggest the console should be working only when you instanciate it in a scene.
I know "toggle" can be called to avoid that but I feel this would make more sense in terms of Godot's design principles and would respect separation of concerns. Having a UI Node seems more fitting because you wouldn't have to edit directly the plugin to make changes.
I know that this is possible in Godot : https://docs.godotengine.org/en/stable/tutorials/plugins/editor/making_plugins.html#a-custom-node
Of course, the new control node would need to be easily modified with an exposed interface : exported variables, functions, signals, etc...
Ideally, users shouldn't have to look at the code of the plugin if they don't need to.
I think this would fit pretty well with #24
The asset library page currently points to an icon URL that doesn't exist, causing warning messages to be printed in the editor console.
Please add an icon.png
to this repository to solve the issue ๐ Its dimensions can be 128ร128 (preferably) or 64ร64.
thanks for very useful addon!
small typo
https://github.com/QuentinCaffeino/godot-console/blob/dev/src/Command/CommandGroup.gd#L85
var command = CommandBuilder.buildDeprecated(lastNamePart, parameters) # Command|int
changing buildDeprecated
to build
make it work
Maybe you can write in the documentation that you can change the number of saved previous commands. (Console.gd
line 30)
Or are there problems if you set the value too high?
Gamemap
I think the code due this
If the console output text box gets really full godot will eventually slow to a crawl. Potentially we should just trim from the top to avoid issues.
I was able to get this functioning i 3.1 but in order to do it I needed to basically remove all of those init scripts that you have.
I did not fully understand how they were being used.
I would think that many of the objects that you have created need to be converted into GDS classes now so that they are registered globally.
I did not make a pull request because I was not sure what your approach to fixing this is.
godot automatic make four space to one tab.
so script not working.
So if you type an invalid command and hit enter the invalid command sticks around.
From my experience (warning: anecdotal) hitting enter should clear the invalid command but add it to the history. If you want to recall the command you'd hit up and adjust it.
As this behavior can be created in 2 line changes in ConsoleLine.gd (091-092) I'd think that this is instead by design? Perhaps some sort of plugin option might be best if it's conflicting design with defacto standard?
Thanks,
Michael Brune
Move CommandGroup to other branch that until it's ready for some usage (autocomplete).
Return old code where regular Dictionary was used cause it used to work.
If I type any letters and press TAB, nothing happens.
Using Godot 3.1.2
I am implementing this console add-on for a client in a networked server-client project.
When my client connects to the server, the client & console addon will dynamically register new commands that get sent from the server.
The problem is that I can only link all the callback functions to the same function as GDScript doesn't allow me to generate new function bodies and link those, see example below:
func consoleAddCommands(commandName : String, commandDescription : String, commandArguments : Dictionary) -> void:
var functionName : String = "sendServerSideCommand" + str(commandArguments.size())
var commandBuilder = Console.add_command(commandName, self,functionName)\
.set_description(commandDescription)
for argumentName in commandArguments:
commandBuilder.add_argument(argumentName,typeof(commandArguments[argumentName]))
commandBuilder.register()
func sendServerSideCommand0(commandName) -> void:
networkhound.send_message("serverSideCommand", [commandName])
func sendServerSideCommand1(commandName, arg0) -> void:
networkhound.send_message("serverSideCommand", [commandName, arg0])
func sendServerSideCommand2(commandName, arg0, arg1) -> void:
networkhound.send_message("serverSideCommand", [commandName, arg0, arg1])
func sendServerSideCommand3(commandName, arg0, arg1, arg2) -> void:
networkhound.send_message("serverSideCommand", [commandName, arg0, arg1, arg2])
=> Etc..
This code does not work because the console add-on does not provide commandName
to the callback functions, a way to circumvent that is to have the user input the same command twice, both as command name and as the 1st argument but this is not ideal.
So each time a callback fires from a dynamically added command, I get the correct variating arguments, but no way of identifying which exact command was executed.
Implementing a way to optionally register some commands that are expected to provide the commandName
as the first argument to their callback functions would be really useful!
I'm using:
Given:
public override void _Ready()
{
// ...
wrapper.AddCommand("start_host", this, nameof(BeginServer))
.SetDescription("beings a dedicated host on %port% with %maxPlayers%. \"")
.AddArgument("port", Variant.Type.Int)
.AddArgument("maxPlayers", Variant.Type.Int)
.Register();
}
public Error BeginServer(int port = 25000, int maxPlayers = 2)
{
// ...
}
the command is successfully registered. If i run the command with arguments provided:
start_host 25000 2
then the command successfully runs. However, if i run the command without some or any arguments provided:
start_host
then I get a runtime error:
E 0:00:04.577 callv: Error calling method from 'callv': 'Spatial(Game.cs)::BeginClient': Method not found..
<C++ Error> Method failed. Returning: Variant()
<C++ Source> core/object.cpp:829 @ callv()
<Stack Trace> Callback.gd:58 @ call()
Command.gd:72 @ execute()
ConsoleLine.gd:112 @ execute()
It would be fantastic to implement this console into a screen within our games. For my use case, I'm building a text editor where the player writes code and submits it through this console, so instead of linking the console to the viewport of the player it would be fantastic if we can instance the console into a separate control node and format the console's UI from the individual scene.
Any help on this topic would be highly appreciated, I'll be working on this feature so feel free to reach out.
So my specific use case is say set_winowed or set_max_fps. Both these commands take arguments of what you are setting the max fps to or if the game should be windowed but in typical game consoles, a lot of times by just putting in set_max_fps without an argument the console will print the current max fps without setting it. Currently because of how the callback system works there doesn't seem like there is a good way to get this functionality but perhaps I am missing an obvious way to achieve this result?
Thanks.
In C#, Console is provided by System, so I can't actually seem to find a way to add a command, from C#.
### Steps:
1. Install godot-console from AssetLibrary or import from a zip file.
2. Open the Project settings and select "Plugins".
3. Enable quentincaffeino-console
4. Error seen below will print to console.
Resource: 'res://addons/quentincaffeino/console/src/Console.tscn' is already being loaded. Cyclic reference?
res://addons/quentincaffeino/console/src/ConsoleLine.gd:34 - Parse Error: The identifier "Console" isn't declared in the current scope.
modules/gdscript/gdscript.cpp:566 - Method failed. Returning: ERR_PARSE_ERROR
### Project:
I've included the project in question for easy of re-creation. Please note that I have enabled dialogic and scatter in my plugin settings.
Demo.zip
Model: Acer Aspire E5-576 V1.49
Distro: Arch Linux x86_64
Kernel: Linux 5.15.10-arch1-1
Desktop Environment: KDE
CPU: 4 x Intel(R) Core(TM) i3-8130U CPU @ 2.20GHz
GPU: Intel Corporation UHD Graphics 620 (rev 07)
RAM: 5811 MiB
Godot Version: 3.4.2.stable.official.45eaa2daf
Happy to provide any additional information as needed. Would love to use this in my project(s)
Well, that's egg on my face. I attached the Node to a scene (it's been a while since I've used Godot proper) and it works perfectly fine now... ๐คฆ๐ป
Read the below message, I had the right idea but I hadn't realized that the console was loaded automatically as a singleton. Whoops.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.