Godot - any way to trace signals?

Signals are an essential feature of Godot scripting , but I'm trudging through molasses because of them.

I keep mistaking the names of signals when dynamically connecting and emitting them (e.g. "start_server" when it was really "create_server"). On top of that, signals kind of go all over the place. Other messaging patterns I've used typically provide a common publisher for listeners to subscribe to, making it easy to listen on and debug communications. In Godot, everything connects directly to everything else. They go up the scene tree, down the tree, and to siblings. Because of this, I'm finding it very frustrating to keep track of what's going where once a game gets even remotely large.

I love everything about this engine, but this is maddening. Is there a way to track these signals so I can mitigate these small, but very frequent and hard to find signal errors?

1 answer

  • answered 2019-01-11 21:01 Jerome Tolentino

    I'm not sure if this is "best practice" but you can make a global gd file for your project that contains constants of all your signal names. If you have a prefix to the signals that you clearly remember it might be easier to have it autocomplete the signal names for you.

    e.g.

    signal_globals.gd const SIG_SERVER_CREATE = "create_server" const SIG_HABADASHER = "habadasher_crasher" ... something.connect(SIG_SERVER_CREATE, this, "_create_server_now")

    Although, theoretically the code completion should be able to do signal names by itself already...