ID:1522108
 
(See the best response by FKI.)
Code:
//if(DEBUG == 1){world << ""}
turf
water
var/Height = 1
water
icon = 'water.dmi'
icon_state = "1"
New()
..()
spawn(1) Begin()
water_source
Height = -1
icon = 'water.dmi'
icon_state = "-1"
New()
..()
spawn(1) Begin()


proc
Begin()
var/I = 1
while(I)
src.icon_state = "[src.Height]"
var/turf/water/north = get_step(src,NORTH)
var/turf/water/east = get_step(src,EAST)
var/turf/water/south = get_step(src,SOUTH)
var/turf/water/west = get_step(src,WEST)
if(!(isnull(north))) //If its not null
if(isturf(north)) //And it is a turf
if(north.density == 0) //If it dosnt have density
if(!(north.type == /turf/water/water_source)) //and its not a water source
if(north.type == /turf/water/water) //Make sure its water
if(src.Height > 1 && north.Height < 7) //If its height is above one, and the water next to it is below 7
src.Height -=1 //Remove 1 height from this water
north.Height += 1 //and add it to the water next to it
if(src.Height == -1 && north.Height < 7) //If its a water source
north.Height += 1 //Add one
else //if its not water
if(src.Height > 1 || src.Height == -1) //And the water has enough to move
if(src.Height > 1) src.Height -= 1 //Remove 1 height from this water unless its a source
new/turf/water/water(north) //and use it to make water over here

if(!(isnull(east))) //If its not null
if(isturf(east)) //And it is a turf
if(east.density == 0) //If it dosnt have density
if(!(east.type == /turf/water/water_source)) //and its not a water source
if(east.type == /turf/water/water) //Make sure its water
if(src.Height > 1 && east.Height < 7) //If its height is above one, and the water next to it is below 7
src.Height -=1 //Remove 1 height from this water
east.Height += 1 //and add it to the water next to it
if(src.Height == -1 && east.Height < 7) //If its a water source
east.Height += 1 //Add one
else //if its not water
if(src.Height > 1 || src.Height == -1) //And the water has enough to move
if(src.Height > 1) src.Height -= 1 //Remove 1 height from this water
new/turf/water/water(east) //and use it to make water over here
if(!(isnull(south))) //If its not null
if(isturf(south)) //And it is a turf
if(south.density == 0) //If it dosnt have density
if(!(south.type == /turf/water/water_source)) //and its not a water source
if(south.type == /turf/water/water) //Make sure its water
if(src.Height > 1 && south.Height < 7) //If its height is above one, and the water next to it is below 7
src.Height -=1 //Remove 1 height from this water
south.Height += 1 //and add it to the water next to it
if(src.Height == -1 && south.Height < 7) //If its a water source
south.Height += 1 //Add one
else //if its not water
if(src.Height > 1 || src.Height == -1) //And the water has enough to move
if(src.Height > 1) src.Height -= 1 //Remove 1 height from this water
new/turf/water/water(south) //and use it to make water over here
if(!(isnull(west))) //If its not null
if(isturf(west)) //And it is a turf
if(west.density == 0) //If it dosnt have density
if(!(west.type == /turf/water/water_source)) //and its not a water source
if(west.type == /turf/water/water) //Make sure its water
if(src.Height > 1 && west.Height < 7) //If its height is above one, and the water next to it is below 7
src.Height -=1 //Remove 1 height from this water
west.Height += 1 //and add it to the water next to it
if(src.Height == -1 && west.Height < 7) //If its a water source
west.Height += 1 //Add one
else //if its not water
if(src.Height > 1 || src.Height == -1) //And the water has enough to move
if(src.Height > 1) src.Height -= 1 //Remove 1 height from this water
new/turf/water/water(west) //and use it to make water over here
sleep(1)

Problem description:
The water acts very strangely, doing only 1 thing at a time, im guessing this is some sort of limitation on byonds side, or im just failing hard at coding :/ what the water does is it will go north til it cant go north anymore do to an obstacle and then it will start heading east, again until it can go anymore, then it goes south 1 and the heads west and starts filling in the area, the var Height determines how much water is in the water turf, and when it heads west everything above where water is placed will go to 5, until it hits the end in which the turf above it should be water and if it is it turns to 7, im using small brick houses as a test, and it goes, makes a area surrounded by water/walls fills it in and then goes to another area, this is very weird behavior and i have no idea what causes it, other then being an issue on byonds side, or because im trying to do to many things at once, could anyone help me?
Best response
It'd help if you re-described the problem using a little punctuation. You'd be surprised how much clearer text can be when you add a couple periods where they belong.
Looks like you want flood fill instead of what ever this is. Also your code can be cut down a lot as right now it's really repetitive. Could you provide a demo?