Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Idleman |
Hello, I am new to Godot and learning how to code. I want to put a light indicator in my game, and basically, if player uses one unit of power, one of the lights goes off. I get this line of code from a tutorial, it is working as planned, but I don’t quite understand the logic of this function. In the spirit of learning, could some one explain how the function works? Specially what the “i” means in the function. Thank you!
func set_light(value):
for i in get_child_count():
if value > i:
get_child(i).texture = light_on
else:
get_child(i).texture = light_off