This commit is contained in:
Crispy 2025-07-04 00:34:24 +02:00
parent 45e6ec6e95
commit ccb5b5d419
3 changed files with 61 additions and 34 deletions

View file

@ -9,13 +9,14 @@ mirror = mirror or false
local TILES = 13
function save(layer)
function save(layer, slice)
fs.delete("progress.lua")
repeat
file = fs.open("progress.lua", "w")
until file
file.write("progress = " .. progress .. "\n")
file.write("layer_start = " .. layer .. "\n")
file.write("slice_start = " .. slice .. "\n")
-- todo save pos separately, more frequently
file.close()
end
@ -46,64 +47,89 @@ end
-- assumes position is on lamp, right in front of the slice to be mined
-- nearest the wall
function clear_tile_slice()
if layer_start == 5 then
-- avoid breaking the existing floor
for _ = 0, progress*8 do
goForward()
end
end
for layer = layer_start, 5 do
save(layer)
local y = 12 - layer * 3
local x = 8
local length = 8 * TILES + 8
if layer == 5 then
x = x - 2
length = length - 2
end
turnLeft = (layer % 2 == 0) ~= mirror
local z = progress*8 + 1 + (layer % 2) * 7
if y < 0 then
-- avoid breaking the existing floor
for _ = 0, progress*8 do
goForward()
end
end
if mirror then
goTo(vector.new(-x,y,z), "east", true)
else
goTo(vector.new(x,y,z), "west", true)
end
for strip = 1, 8 do
for slice = slice_start, 7 do
save(layer, slice)
local y = 12 - layer * 3
local x = 8
if layer == 5 then
x = x - 2
end
turnLeft = ((layer + slice) % 2 == 0) ~= mirror
local z = progress * 8 + 1-- + (layer % 2) * 7
if layer % 2 == 0 then
z = z + slice
else
z = z + 7 - slice
end
local face = mirror and "east" or "west"
if slice % 2 == 1 then
x = x - length
face = rightOf[rightOf[face]]
end
if mirror then
x = -x
end
print("going to", x,y,z,face)
goTo(vector.new(x,y,z), face, true)
-- print("arrived")
-- read()
for _ = 1, length do
mine3_step()
end
if strip == 8 then
if slice == 8 then
turtle.digUp()
turtle.digDown()
else
turn()
mine3_step()
turn()
turnLeft = not turnLeft;
-- turnLeft = not turnLeft;
end
end
slice_start = 0
goLeft()
goLeft()
end
progress = progress + 1
save(0, 0)
end
function refuel()
if turtle.getFuelLevel() < 19500 then
goTo(vector.new(0,0,0), "north")
while turtle.getFuelLevel() < 20000 do
turtle.suck()
turtle.refuel()
end
turtle.drop()
goHome()
end
end
goHome()
refuel()
clear_tile_slice()
progress = progress + 1
save(0)
for i = 1, 16 do
turtle.select(i)
turtle.drop()
end
turtle.select(1)
goHome()
goLeft()
goLeft()
while turtle.getFuelLevel() < 20000 do
turtle.suck()
turtle.refuel()
end
turtle.drop()
goLeft()
goLeft()
refuel()