More elegant way for signals

I have an “issue” where I got 2 pieces of code that pretty much do the same thing but I do not know how to make it shorter:

func _on_stone_clicker_scene_update_unlocks() → void:
show_buttons_unlock();
pass # Replace with function body.

func _on_coal_clicker_scene_update_unlocks() → void:
show_buttons_unlock();
pass # Replace with function body.

These are 2 signals from 2 different nodes that come into the same script and then get handled the exact same way, is it possible to “merge” them within one signal?

2 Likes

You can connect the same function to multiple signals.

7 Likes

If you look closer at the menu when setting up the signal, you can select “pick” or something like that, and select which function to connect it to.
Or connect it through code

4 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.