turf
grass
icon='LOZTILES.dmi'
icon_state="g1"
DblClick()
if(icon_state == "g1")
icon_state = "g2"
if(src.icon_state == "g2")
icon_state = "g3"
if(icon_state == "g3")
icon_state = "g4"
if(icon_state == "g4")
icon_state = "g5"
if(icon_state == "g5")
icon_state = "g6"
if(icon_state == "g6")
icon_state = "g7"
if(icon_state == "g7")
icon_state = "g8"
if(icon_state == "g8")
icon_state = "g9"
if(icon_state == "g9")
icon_state = "g1"
Problem description:For some reason this bit of code doesnt work at all and its really grinding my gears :\ Its supposed to change the icon state when you click it
To make this a bit clearer, try imagining what happens when you double-click on it: if the icon state is "g1", it gets set to "g2", then it checks to see if it is equal to "g2", and sets it to "g3", and so on.
The best solution is to simply add "else" before all the if lines except the first:
That will cause it to skip the rest of the if statements after one of them executes.