:3
This commit is contained in:
parent
491112768c
commit
68ec37f994
66 changed files with 6591 additions and 10096 deletions
106
computer/26/expand.lua
Normal file
106
computer/26/expand.lua
Normal file
|
@ -0,0 +1,106 @@
|
|||
require("path")
|
||||
pp = require("cc.pretty").pretty_print
|
||||
|
||||
require("progress")
|
||||
|
||||
-- mirror = wall is to the right
|
||||
local mirror = true
|
||||
mirror = mirror or false
|
||||
|
||||
local TILES = 13
|
||||
|
||||
function save(layer)
|
||||
fs.delete("progress.lua")
|
||||
repeat
|
||||
file = fs.open("progress.lua", "w")
|
||||
until file
|
||||
file.write("progress = " .. progress .. "\n")
|
||||
file.write("layer_start = " .. layer .. "\n")
|
||||
-- todo save pos separately, more frequently
|
||||
file.close()
|
||||
end
|
||||
|
||||
function mine_step()
|
||||
repeat
|
||||
turtle.dig()
|
||||
until goForward()
|
||||
end
|
||||
|
||||
function mine3_step()
|
||||
turtle.digUp()
|
||||
turtle.digDown()
|
||||
repeat
|
||||
turtle.dig()
|
||||
until goForward()
|
||||
end
|
||||
|
||||
local turnLeft = true
|
||||
function turn()
|
||||
if turnLeft then
|
||||
goLeft()
|
||||
else
|
||||
goRight()
|
||||
end
|
||||
end
|
||||
|
||||
-- assumes position is on lamp, right in front of the slice to be mined
|
||||
-- nearest the wall
|
||||
function clear_tile_slice()
|
||||
for layer = layer_start, 5 do
|
||||
save(layer)
|
||||
local y = 12 - layer * 3
|
||||
local x = 9
|
||||
local length = 8 * TILES + 9
|
||||
if layer == 5 then
|
||||
x = x - 3
|
||||
length = length - 3
|
||||
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 _ = 1, length do
|
||||
mine3_step()
|
||||
end
|
||||
if strip ~= 8 then
|
||||
turn()
|
||||
mine3_step()
|
||||
turn()
|
||||
turnLeft = not turnLeft;
|
||||
end
|
||||
end
|
||||
goLeft()
|
||||
goLeft()
|
||||
end
|
||||
end
|
||||
|
||||
goHome()
|
||||
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()
|
Loading…
Add table
Add a link
Reference in a new issue