This commit is contained in:
Crispy 2025-05-27 03:02:53 +02:00
parent 1ff3cea4d6
commit 5422d52065
21 changed files with 21953 additions and 369 deletions

View file

@ -2,7 +2,8 @@ sf = require("structure")
local pf = require("pathfinding")
local im = require("inventorymanager")
local origin = vector.new(-15,235,120)
function build(x,y,z)
function build(chunk)
local x,y,z = stringtovec(chunk)
store = {height = 0}
grocerylist = {}
for h = 1,8 do
@ -27,14 +28,14 @@ function build(x,y,z)
end
end
if store.height==0 then
--print("cell at",x,y,z,"is done")
removechunk(x,y,z)
print("cell at",x,y,z,"is done")
return true
end
flag = false
count = im.countinventory()
for k,v in pairs(grocerylist) do
if im.count(k) < v then
if (count[k] or -1) < v then
print("not enough "..k.." need "..v.." of it")
flag = true
end
@ -49,11 +50,13 @@ function build(x,y,z)
return false
end
pf.to(origin + vector.new(x+1,y+8,z+1))
for h = 1,8 do
print(store[h].width)
for w = 1,store[h].width do
print(store[h][w].depth)
for d = 1,store[h][w].depth do
--print("going")
--pf.to(origin+vector.new(1,1,1))
--im.select("minecraft:barrel")
--turtle.placeDown()
for w = 1,8 do
for h = 1,8 do
for d = 1,8 do
if store[h][w][d] then
pf.to(origin+vector.new(x+w,y+h,z+d))
im.select(store[h][w][d])
@ -62,55 +65,21 @@ function build(x,y,z)
end
end
end
removechunk(x,y,z)
return true
end
function removechunk(x,y,z)
--::success::
local file = fs.open("tobuild","r")
local rest = {}
line = file.readLine()
while line do
table.insert(rest,line)
line = file.readLine()
end
file.close()
file = fs.open("tobuild","w")
str = tostring(vector.new(x,y,z))
for _,v in ipairs(rest) do
if v ~= str then
file.writeLine(v)
end
end
file.close()
end
function stringtovec(str)
parts = {}
for part in string.gmatch(str, "([^,]+)") do
table.insert(parts, part)
table.insert(parts, tonumber(part))
end
return vector.new(unpack(parts))
end
--pf.to(origin)
file=fs.open("tobuild","r")
chunk = file.readLine()
file.close()
print(chunk)
vec = stringtovec(chunk)
X1,Y1,Z1 = vec.x,vec.y,vec.z
print(X1,Y1,Z1)
while build(X1,Y1,Z1) do
-- term.clear()
print(X1,Y1,Z1)
file = fs.open("tobuild","r")
chunk = file.readLine()
vec = stringtovec(chunk)
X1,Y1,Z1 = vec.x,vec.y,vec.z
file.close()
--term.clear()
sleep(0)
return unpack(parts)
end
pf.returnHome()
repeat
rednet.send(1,nil,"getnexttobuild")
print(chunk)
_,chunk = rednet.receive("nexttobuild")
until not build(chunk)
rednet.send(1,chunk,"failedtobuild")
pf.returnHome()