You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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!
The text was updated successfully, but these errors were encountered:
I've been thinking about giving users an ability to create custom commands and creating aliases for already existing commands which would solve your issue and give a very nice structure to the code. But I don't have much time to implement that so in the mean time if you are fine with a temporary solution I can add an optional flag to CommandBuilder which is going to be removed later when I implement a proper way of doing this stuff.
This is the example of my proposal:
Console.add_command("cmdname", self, "funcname")\
...
.pass_command_name() # It would also accept an optional boolean as an argument in case someone decides to enable/disable this behaviour
...
.register()
Thanks to your suggested proposal I have been able to implement this quickly in a pretty rough and non-idiomatic way with small modifications to Command.gd and CommandBuillder.gd which suffices for my case.
So please, if no one else requires such functionality other than me, perhaps you do not need to implement it, because I do have a quickly mashed up version of this working now!
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:
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!The text was updated successfully, but these errors were encountered: