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

Var servant amount = 1
Func on checkbutton toggle ( buttonpressed):
If servant amount = 0:
Checkbutton.disabled = true
Elif button
Servant amount -= 1
Servant amount += 1

Ok so i have something like this for my code. What i want it that of the player doesn’t have servant available he can’t toggle the button.
If he has servant available he can toggle the button to turn it on when this happens it take away 1 servant.
If the player toggle off the checkbutton then he will receive the servant back.

Godot version Latest
in Engine by (22 points)

1 Answer

0 votes
Best answer

Now this is a hard one since your code is an infinite loop that achieves nothing.

The only way to get what you want is to offset your code to another button or part in your script, most likely the focus_entered signal.

var servant_amount = 1

func on_checkbutton_toggle ( button_pressed):
    if button_pressed:
        servant_amount -= 1
        servant_amount += 1

func on_checkbutton_focus_entered():
    $Checkbutton.disabled = servant_amount == 0
by (6,942 points)
selected by
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.