How to not reset an extra call argument of a signal in an instance after game start?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MaaaxiKing

I have a Scene with a Button and this Button has a Script. The Button is connected to its script via the signal function _on_Button_pressed(mode). mode is the extra call argument and of type String. Now, the problem is that I’ve set a default value for mode and I have 5 instances of the Button in another scene. Unfortunately, I want one of these buttons to have a different value for mode but everytime I start the game, this value will be overriden because all Scenes are going to be saved.
Is there an easier way than changing its value after the game start through one line of script ($Button.connect("pressed", self, "_on_Button_pressed", [other_value_than_default])?

:bust_in_silhouette: Reply From: Lopy

I believe you would be better of having mode as an exported variable. That way, you can set your mode just like you do with other properties on the right pane.

Buttons already have a _pressed() function that you can override. The signal is mostly there for Buttons without scripts;

If one does not want something to happen at the moment a Button was pressed, the signal is useless for the one. But the idea with export is great, thank you very much!

MaaaxiKing | 2020-12-27 21:06