This code is causing me some problems. The idea is to create rivers that can make themselves at runtime, and this particular example should end up with the entire world being full of water. However, it seems like water is vanishing somehow. The flow() procedure for the spring is being called every half a second, like it should, but it's waterlevel is always the same. It is always two. It spreads out to one turf on the map that has an altitude of zero, and ends up with a waterlevel of three. Nothing happens after that. The game doesn't lock, the waterlevel just doesn't change. Whats going on?
turf
icon='turf.dmi'
var/altitude=0
var/waterlevel=0
proc/Flow()
set background=1
for(var/turf/t2 in range(1,src))
if((t2.altitude+t2.waterlevel)<(altitude+waterlevel))
while((t2.altitude+t2.waterlevel)<(altitude+waterlevel))
t2.waterlevel++
waterlevel--
if(waterlevel<=0) break
spawn(5) t2.Flow()
if(waterlevel>0) icon_state="water"
else icon_state=initial(icon_state)
verb/Check()
set src in world
usr << "Altitude:[altitude], Waterlevel:[waterlevel]"
grass
icon_state="grass"
spring
icon_state="water"
waterlevel=2
New()
..()
spawn(5) Flow()
Flow()
..()
waterlevel+=2
spawn(5) Flow()
EDIT:
Adding this code:
t2.overlays+=image('turf.dmi',t2,"water")
Makes it work properly for some reason. I don't even have to output the image. It's added under the start of the For() loop.
-Kosh