fix: correct movement logic
This commit is contained in:
parent
9a8f81e428
commit
ef808abb94
1 changed files with 3 additions and 7 deletions
10
mine.lua
10
mine.lua
|
|
@ -212,8 +212,6 @@ function dropOffItems (starting_point, go_back)
|
||||||
print("Time to drop off what I got")
|
print("Time to drop off what I got")
|
||||||
-- Turn off mining
|
-- Turn off mining
|
||||||
mode.mine = { forward = true }
|
mode.mine = { forward = true }
|
||||||
-- Note current position (assuming facing FORWARD)
|
|
||||||
local pos_state = getCurrentPos()
|
|
||||||
-- Return to origin, facing BACK
|
-- Return to origin, facing BACK
|
||||||
moveAbs(starting_point)
|
moveAbs(starting_point)
|
||||||
moveAbs(V_ZERO)
|
moveAbs(V_ZERO)
|
||||||
|
|
@ -224,10 +222,9 @@ function dropOffItems (starting_point, go_back)
|
||||||
turtle.drop()
|
turtle.drop()
|
||||||
end
|
end
|
||||||
turtle.select(1)
|
turtle.select(1)
|
||||||
-- Return to current position, facing forward
|
-- Return to the mining zone, facing forward
|
||||||
if go_back then
|
if go_back then
|
||||||
moveAbs(starting_point)
|
moveAbs(starting_point)
|
||||||
moveAbs(pos_state)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -324,14 +321,13 @@ function split (block)
|
||||||
end
|
end
|
||||||
|
|
||||||
function process (stack, starting_point)
|
function process (stack, starting_point)
|
||||||
-- fuel and go to starting point
|
|
||||||
refuelUntil(FUEL_RESERVE)
|
refuelUntil(FUEL_RESERVE)
|
||||||
mode.mine = { forward = true }
|
mode.mine = { forward = true }
|
||||||
if #stack == 0 then return nil end
|
if #stack == 0 then return nil end
|
||||||
|
checkAndDropOff(starting_point)
|
||||||
local working = table.remove(stack):orient(getCurrentPos())
|
local working = table.remove(stack):orient(getCurrentPos())
|
||||||
print("Working:", working:tostring())
|
print("Working:", working:tostring())
|
||||||
if canMine(working) then
|
if canMine(working) then
|
||||||
checkAndDropOff(starting_point)
|
|
||||||
mine(working)
|
mine(working)
|
||||||
else
|
else
|
||||||
local new, remainder = split(working, mode.v)
|
local new, remainder = split(working, mode.v)
|
||||||
|
|
@ -349,7 +345,7 @@ function run (v1, v2)
|
||||||
|
|
||||||
process({ block }, starting_point)
|
process({ block }, starting_point)
|
||||||
-- return to base
|
-- return to base
|
||||||
dropOffItems(starting_point)
|
dropOffItems(starting_point, false)
|
||||||
turnToFace(FORWARD)
|
turnToFace(FORWARD)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue