Editor detecting if a passed signal was emitted possible?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By rakkarage
signal test()

# func a():
# 	emit_signal("test")

func b():
	c("test")

func c(s):
	emit_signal(s)

The signal ‘test’ is declared but never emitted.

I have a few signals I wanted to route through one function, because a lot of the code is the same, and I can just pass in the signal, but gives me warnings… :frowning:

Thanks.

:bust_in_silhouette: Reply From: njamster

In the script you provided this is true because you never actually call b(), e.g.:

func _ready():
    b()

However, even if you do this, the warning won’t be gone. But it will work:

signal test()

func _ready():
	connect("test", self, "_on_test")
	b()

func b():
	c("test")

func c(s):
	emit_signal(s)

func _on_test():
	print("It works")

But why the warning then? Because the GDScript parser won’t recognize that you actually do emit the signal, albeit using a variable argument. Try this:

func c(s):
    match s:
        "test":
            emit_signal("test")

If that’s no option for you, you can also disable the warning under Project > Project Settings… > Debug > Gdscript > Unused Signal or add an exception with:

#warning-ignore:unused_signal
signal test()

Hmmm… Beat me to it… ;^)

jgodfrey | 2020-05-08 00:31

:bust_in_silhouette: Reply From: jgodfrey

So, what’s the question exactly?

I assume because of the indirection involved with your signal setup, it’s not being detected by the engine, which generates a warning.

And, it is just a warning. You can do a few things here…

  • Just don’t pay any attention to it.
  • Tell Godot to ignore that single instance of the warning by clicking the small yellow warning symbol in the status bar of the code editor and choosing the provided ignore link.
  • Ignore all such warnings via Project | Project Settings | Debug | Gdscript | Unused signal

However, I’d recommend that you don’t blindly ignore warnings (without understanding why your ignoring them) as, generally, they are there to assist you…