Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Suggestion] Reset to default #56

Open
andersmmg opened this issue Feb 27, 2021 · 3 comments
Open

[Suggestion] Reset to default #56

andersmmg opened this issue Feb 27, 2021 · 3 comments

Comments

@andersmmg
Copy link

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.

@andersmmg andersmmg changed the title Reset to default [Suggestion] Reset to default Feb 28, 2021
@quentincaffeino
Copy link
Owner

quentincaffeino commented Mar 2, 2021

I'm not sure if this is really required feature but I would like to hear what others (lets hope there are others)) have to say.

Generally I would suggest removing commands yourself by subscribing to node destruct signal since it is faster, it should make code clearer that when you register command and remove it on node removal.

But if you absolutely need to remove everything besides default commands I can come up with this quick solution:

const CommandCollection = preload('res://addons/quentincaffeino-console/src/Command/CommandCollection.gd')

func remove_custom_commands():
	Console.get_command_service()._command_collection = CommandCollection.new()
	Console.BaseCommands.new(Console)

(haven't actually tested this code, wrote it right here in gh issues)

But this solution might stop working anytime since it's using private interfaces so I highly suggest considering the first solution.

@Gamemap
Copy link
Contributor

Gamemap commented Mar 2, 2021

I think this function would be useful. (If it is not too complicated to implement)

@Lyaaaaaaaaaaaaaaa
Copy link
Contributor

@andersmmg, maybe you can use the function remove_command Doc link to delete your custom commands? It requires the command name, so maybe you can store your custom commands' names in an array then for each entry of that array call remove_command to reset to default.

However, a function to reset could be pretty useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants