Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local done = {}
- local temp = {{map.pos[1], map.pos[2], 0, false}}
- while #temp > 0 do
- local ntemp = {}
- for i=1,#temp do
- local x = temp[i][1]
- local y = temp[i][2]
- local n = temp[i][3]
- local sl = temp[i][4]
- local dtyp = map[x][y][1]
- if sl == false then
- for o=-1,1,2 do
- local nposs = {{x+o, y}, {x, y+o}}
- for j=1,#nposs do
- local npos = nposs[j]
- if map[npos[1]] ~= nil then
- if map[npos[1]][npos[2]] ~= nil then
- local typ = map[npos[1]][npos[2]][1]
- if typ == 1 or typ == 2 or typ == 3 or typ == 4 or typ == 5 or typ == 6 then
- local ok = false
- local stopLoop = false
- if typ == 6 then stopLoop = true end
- if done[npos[1]] == nil then
- ok = true
- else
- if done[npos[1]][npos[2]] == nil then
- ok = true
- end
- end
- if ok then
- if n+1 <= radius then
- ntemp[#ntemp + 1] = {npos[1], npos[2], n+1, stopLoop}
- end
- end
- end
- end
- end
- end
- end
- end
- if done[x] == nil then done[x] = {} end
- done[x][y] = {dtyp, false, n}
- end
- temp = ntemp
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement