Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | lonnwolf031 |
I am making a multiplayer dice game. At this moment I struggle with disabling a button.
I want the ‘roll dice’ button to be disabled if it’s not the players turn of when the current player already pressed the button. I haven’t tested with multiple users yet, but when I test it I am still able to press the button multiple times. I tried several ways, and the code for disabling a button I’ve looked up and gives no errors.
Here is some relevant code, as you can see I tried multiple places for disabling the button, but none of them seem to work.
onready var _action = $VBoxContainer/HBoxContainer/SubVBoxContainer/Action
func _on_RollButton_pressed():
if get_tree().is_network_server():
do_action("roll")
print("roll is done")
#disable button
_action.set_disabled(true)
next_turn()
else:
rpc_id(1, "request_action", "roll")
sync func set_turn(turn):
_turn = turn
if turn >= _players.size():
return
for i in range(0, _playersDict.size()):
if i == turn:
_action.disabled = false
#_playByRulesRolledDice()
#_list.set_item_icon(i, _crown)
pass
else:
#_playByRulesOthers()
#_list.set_item_icon(i, null)
pass
if _players[turn] != get_tree().get_network_unique_id():
_action.disabled = true
elif clicked == true:
_action.disabled = true
else:
_action.disabled = false
Are you sure the _action.set_disabled(true)
is actually referencing the button node itself?
Tato64 | 2021-04-12 17:44