This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I have a toogle TextureButton. It turns on an ability IF the player is level 19 or higher. The problem is, if the player is too low of level, I want to manually turn off the button. I have to use AbilityButton.pressed = false which then calls the toggled function again. Is there a way to catch the button toggled before it actually draws the PRESSED state, then manually turn the state to NORMAL, and cancel the event so it doesn't call the toggled function at all?

in Engine by (422 points)

1 Answer

0 votes

just put all the code you used for toggle button in a if statement.
Say if player.level > 18: then all your codes under this if statement will only run if the player is level 19 and above, so even if the button is pressed, the button will do nothing unless the player is level 19 and above.

by (271 points)

The problem is, by the time the code reaches the toggled function, the actual button has changed appearance.
Therefore, I have to manually change the toggled button state to false. By doing this, it calls the toggled function again.
I want to catch the button before it ever reached the Toggled signal to stop the appearance change at the very root of the event.

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 Frequently asked questions and 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 [email protected] with your username.