mine.lua: rewrite checkpoint 3

This commit is contained in:
Emerson Rosen-Jones 2025-12-01 21:11:07 -05:00
parent f4444cd120
commit e4b9438119

View file

@ -168,7 +168,7 @@ function move (v)
turnToFace(LEFT) turnToFace(LEFT)
moveInLine(-v.x) moveInLine(-v.x)
end end
mode.v = mode.v + UNIT_X mode.v.x = mode.v.x + v.x
-- z -- z
if v.z > 0 then if v.z > 0 then
turnToFace(FORWARD) turnToFace(FORWARD)
@ -178,10 +178,10 @@ function move (v)
turnToFace(BACK) turnToFace(BACK)
moveInLine(-v.z) moveInLine(-v.z)
end end
mode.v = mode.v + UNIT_Z mode.v.z = mode.v.z + v.z
-- y -- y
moveUpDown(v.y) moveUpDown(v.y)
mode.v = mode.v + UNIT_Y mode.v.y = mode.v.y + v.y
end end
-------------- DROPPING OFF AND REFUELING ------------------- -------------- DROPPING OFF AND REFUELING -------------------
@ -302,31 +302,6 @@ function process (stack, starting_point)
return process (stack) return process (stack)
end end
function calculateBlock (v1, v2)
-- Using the coordinates, construct a block of certain dimensions, a
-- certain distance away.
local block = {}
local normalize = function (dim, c1, c2)
-- pick the closest point
-- offset goes to the other point
local corner, offset
if math.abs(c1) <= math.abs(c2) then
corner, offset = c1, c2 - c1
else
corner, offset = c2, c1 - c2
end
block[dim] = corner
block[dim .. "off"] = offset
end
normalize("x", v1.x, v2.x)
normalize("y", v1.y, v2.y)
normalize("z", v1.z, v2.z)
return new_block(
vector.new(block.x, block.y, block.z),
vector.new(block.xoff, block.yoff, block.zoff)
)
end
function run (v1, v2) function run (v1, v2)
-- TODO calculate starting_point, the place turtle will move to before -- TODO calculate starting_point, the place turtle will move to before
-- moving to the first corner of block -- moving to the first corner of block