0 votes

I have this code:
enter image description here

I need to handle any signal from any node and send it to the "signal handler". The signal handler needs to know all the parameters emitted along with the signal and other parameters (added using array binding).

In the signal handler I have the following (not working):
enter image description here

But I need something like this (to be able to handle multiple cases):
enter image description here

Any way to do this?

Godot version 3.3.3
in Engine by (254 points)

1 Answer

+1 vote

I only code in GSL, so my advice may not be applicable by Your case, but..

it looks like You want to achieve classic observer pattern there. At least with GSL it is more practical to only introduce all signals by name in signal handler node. With this approach emitter nodes don't emit signal by themselves, but call emit() of signal handler, with all arguments they want to bind for this. Receiver nodes can than connect themelves to signals of their interests, always connecting to signal handler.

by (7,447 points)

I need something like that, but I can't create a function (in c#) for each signal. Any way to connect any signal (from any node) to a single defined function? I need to expose this functionality to users at runtime so I can't manually create the bindings.

I wish I could help but I have no idea about c# limitations.

You say You need a way to connect every various signal to one function. In GSL I would use one signal for every node but with varying bindings, or with one bound dictionary.

Maybe I could come up with some universal sollution if You said something about this project, what are those signals used for in game and how does user change it in runtime ?

I'm porting RPG Maker VX Ace to use godot as "runtime". RM has many limitations, I can't export to any OS other than Windows, it uses GDI as graphical API...

I've done a lot of things, most of the core is already running (sprites, bitmaps, audio, tilemap...). Now I'm trying to integrate Godot's features and expose them to be used in rpg maker scripts.

I want to be able to create scenes using godot and use them within the game. The hard part is that I can't directly wire the node's signals to a ruby callback, nor can I use a lambda to handle a signal (it would be much easier that way).

The most important thing is that I will be able to use the godot ui resources from the rpg maker scripts, this is essential. I can manually configure the signals in this case, but this will restrict users and they will not be able to create custom controls with custom signals.

I'm using C# because of the async features and because IronRuby matches the exact version used in the rpg maker (ruby 1.9, yeah...).

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.