:3c
This commit is contained in:
parent
45e6ec6e95
commit
ccb5b5d419
3 changed files with 61 additions and 34 deletions
|
@ -9,13 +9,14 @@ mirror = mirror or false
|
||||||
|
|
||||||
local TILES = 13
|
local TILES = 13
|
||||||
|
|
||||||
function save(layer)
|
function save(layer, slice)
|
||||||
fs.delete("progress.lua")
|
fs.delete("progress.lua")
|
||||||
repeat
|
repeat
|
||||||
file = fs.open("progress.lua", "w")
|
file = fs.open("progress.lua", "w")
|
||||||
until file
|
until file
|
||||||
file.write("progress = " .. progress .. "\n")
|
file.write("progress = " .. progress .. "\n")
|
||||||
file.write("layer_start = " .. layer .. "\n")
|
file.write("layer_start = " .. layer .. "\n")
|
||||||
|
file.write("slice_start = " .. slice .. "\n")
|
||||||
-- todo save pos separately, more frequently
|
-- todo save pos separately, more frequently
|
||||||
file.close()
|
file.close()
|
||||||
end
|
end
|
||||||
|
@ -46,64 +47,89 @@ end
|
||||||
-- assumes position is on lamp, right in front of the slice to be mined
|
-- assumes position is on lamp, right in front of the slice to be mined
|
||||||
-- nearest the wall
|
-- nearest the wall
|
||||||
function clear_tile_slice()
|
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
|
for layer = layer_start, 5 do
|
||||||
save(layer)
|
|
||||||
local y = 12 - layer * 3
|
|
||||||
local x = 8
|
|
||||||
local length = 8 * TILES + 8
|
local length = 8 * TILES + 8
|
||||||
if layer == 5 then
|
if layer == 5 then
|
||||||
x = x - 2
|
|
||||||
length = length - 2
|
length = length - 2
|
||||||
end
|
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
|
for _ = 1, length do
|
||||||
mine3_step()
|
mine3_step()
|
||||||
end
|
end
|
||||||
if strip == 8 then
|
if slice == 8 then
|
||||||
turtle.digUp()
|
turtle.digUp()
|
||||||
turtle.digDown()
|
turtle.digDown()
|
||||||
else
|
else
|
||||||
turn()
|
turn()
|
||||||
mine3_step()
|
mine3_step()
|
||||||
turn()
|
turn()
|
||||||
turnLeft = not turnLeft;
|
-- turnLeft = not turnLeft;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
slice_start = 0
|
||||||
goLeft()
|
goLeft()
|
||||||
goLeft()
|
goLeft()
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
goHome()
|
goHome()
|
||||||
|
refuel()
|
||||||
clear_tile_slice()
|
clear_tile_slice()
|
||||||
progress = progress + 1
|
|
||||||
save(0)
|
|
||||||
for i = 1, 16 do
|
for i = 1, 16 do
|
||||||
turtle.select(i)
|
turtle.select(i)
|
||||||
turtle.drop()
|
turtle.drop()
|
||||||
end
|
end
|
||||||
turtle.select(1)
|
turtle.select(1)
|
||||||
goHome()
|
goHome()
|
||||||
goLeft()
|
refuel()
|
||||||
goLeft()
|
|
||||||
while turtle.getFuelLevel() < 20000 do
|
|
||||||
turtle.suck()
|
|
||||||
turtle.refuel()
|
|
||||||
end
|
|
||||||
turtle.drop()
|
|
||||||
goLeft()
|
|
||||||
goLeft()
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ _G.pos = _G.pos or vector.new(0,0,0)
|
||||||
|
|
||||||
local up = vector.new(0,1,0)
|
local up = vector.new(0,1,0)
|
||||||
|
|
||||||
local rightOf = {
|
rightOf = {
|
||||||
south = "west",
|
south = "west",
|
||||||
west = "north",
|
west = "north",
|
||||||
north = "east",
|
north = "east",
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
progress = 2
|
progress = 2
|
||||||
layer_start = 0
|
layer_start = 2
|
||||||
|
slice_start = 4
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue