Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | nonomiyo |
Hello, I’m looking for a way to simplify this piece of code :
onready var colo;
onready var characterlist = [0,0,0,0,0,0]; # red / blue / yellow / black
if characterlist[0] == 0 :
characterlist[0] = 1
colo = "red"
elif characterlist[1] == 0 :
characterlist[1] = 1
colo = "blue"
elif characterlist[2] == 0 :
characterlist[2] = 1
colo = "yellow"
elif characterlist[3] == 0 :
characterlist[3] = 1
colo = "black"
It’s checking if the next colour in line is being used, and use it if available.
How can I do that more efficiently please ?