Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function fill(copyIN,x,y,fill)
- local copy = copyIN
- local tile = copyIN[y][x]
- copy[y][x] = "a"
- local filling = true
- local m = {}
- for i = 1, 19 do
- m[i] = {}
- end
- for i = 1, 19 do
- for j = 1, 51 do
- m[i][j] = tile
- end
- end
- while filling do
- filling = false
- for i = 1, 17 do
- for j = 1, 51 do
- if copy[i][j] == "a" then
- for k = 1, 4 do
- if k == 1 and j < 51 then
- if copy[i][j + 1] == tile then
- m[i][j + 1] = "a"
- filling = true
- elseif copy[i][j + 1] == "a" then
- m[i][j + 1] = fill
- end
- elseif k == 2 and i < 17 then
- if copy[i + 1][j] == tile then
- m[i + 1][j] = "a"
- filling = true
- elseif copy[i + 1][j] == "a" then
- m[i + 1][j] = fill
- end
- elseif k == 3 and j > 1 then
- if copy[i][j - 1] == tile then
- m[i][j - 1] = "a"
- filling = true
- elseif copy[i][j - 1] == "a" then
- m[i][j - 1] = fill
- end
- elseif k == 4 and i > 1 then
- if copy[i - 1][j] == tile then
- m[i - 1][j] = "a"
- filling = true
- elseif copy[i - 1][j] == "a" then
- m[i - 1][j] = fill
- end
- end
- end
- m[i][j] = fill
- end
- end
- end
- for i = 1, 17 do
- for j = 1, 51 do
- if copy[i][j] == tile then
- copy[i][j] = m[i][j]
- end
- end
- end
- end
- for i = 1, 17 do
- for j = 1, 51 do
- if copy[i][j] == "a" or copy[i][j] == "b" then
- copy[i][j] = fill
- end
- end
- end
- return copy
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement