53 lines
1.2 KiB
Lua
53 lines
1.2 KiB
Lua
|
|
function stringtovec(str)
|
|
parts = {}
|
|
for part in string.gmatch(str,"([^,])") do
|
|
table.insert(parts,part)
|
|
end
|
|
return vector.new(unpack(parts))
|
|
end
|
|
sf = require("structure")
|
|
|
|
function removechunks()
|
|
file = fs.open("tobuild","r")
|
|
lines = {}
|
|
line = file.readLine()
|
|
|
|
while line do
|
|
i = math.mod((i or 0)+1,100)
|
|
if i == 0 then sleep(0.05) end
|
|
xyz = stringtovec(line)
|
|
if not chunkisempty(xyz) then
|
|
table.insert(lines,line)
|
|
print(line)
|
|
end
|
|
line = file.readLine()
|
|
end
|
|
file.close()
|
|
fs.delete("tobuildcopy")
|
|
file = fs.open("tobuildcopy","w")
|
|
for i,line in ipairs(lines) do
|
|
file.writeLine(line)
|
|
print(line)
|
|
if math.mod(i,100) == 0 then sleep(0.05) end
|
|
end
|
|
file.close()
|
|
end
|
|
function chunkisempty(vec)
|
|
x,y,z = vec.x,vec.y,vec.z
|
|
for w = 1,8 do
|
|
for h = 1,8 do
|
|
for d = 1,8 do
|
|
bool,block = sf.blockat(x+w,z+d,y+h)
|
|
if bool then
|
|
print(block)
|
|
return false
|
|
end
|
|
end
|
|
end
|
|
end
|
|
return true
|
|
end
|
|
|
|
--print(chunkisempty(vector.new(-150,0,0)))
|
|
removechunks()
|