Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | nonomiyo | |
Old Version | Published before Godot 3 was released. |
Hello, I’m new in Godot and in programming so still trying to figure out how everything works. I’m trying to set all my buttons to disabled. (I simplified my issue here, by using only 2 buttons) :
#getting the nodes' paths for all the buttons :
export (NodePath) var button1_path
onready var button1 = get_node(button1_path)
export (NodePath) var button2_path
onready var button2 = get_node(button2_path)
#setting the array
var buttonsarray = [button1, button2]
#and that's where I have no idea what to do.. I don't get how 'for loops' work :/
for entry in buttonsarray:
entry.set_disabled(true)
Any help would be appreciated !
Thanks !
where the var buttonslist
is declared?
out side of functions?
volzhs | 2017-09-17 17:04
no, the only things outside this script are the ‘button1 path’ and ‘button2 path’ which are in the inspector.
Maybe I should have called it Array instead of List… I just edited the original post changing “list” with “array”. Sorry for the confusion
Isn’t this how you declare an array ? :
var buttonsarray = [button1, button2]
nonomiyo | 2017-09-17 18:07
any error on debug output when run it?
volzhs | 2017-09-17 18:54
no errors when I play the scene, but I get
" Invalid call. Nonexistent function ‘set_disabled’ in base ‘Nil’."
when clicking the button
nonomiyo | 2017-09-17 19:44