0 votes

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])?

Godot version 3.2.3.stable
in Engine by (377 points)

1 Answer

0 votes

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;

by (2,442 points)

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!

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 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 webmaster@godotengine.org with your username.