fix(robot-api): mutateRobotPosition
This commit is contained in:
parent
1b3a46e608
commit
f75f280193
@ -145,16 +145,9 @@ local function mineProcedure()
|
|||||||
|
|
||||||
-- 1. Move
|
-- 1. Move
|
||||||
if robotState.y > targetY then
|
if robotState.y > targetY then
|
||||||
local ok, err = turtle.digDown()
|
turtle.digDown()
|
||||||
|
|
||||||
if not ok then
|
|
||||||
error('Cannot dig down because ' .. err)
|
|
||||||
end
|
|
||||||
|
|
||||||
miner.robot.down()
|
miner.robot.down()
|
||||||
elseif robotState.dir == 'FORWARD' and robotState.z < targetZ then
|
elseif robotState.dir == 'FORWARD' and robotState.z < targetZ then
|
||||||
-- TODO: remove this print (debug purpose)
|
|
||||||
print(robotState.z, targetZ)
|
|
||||||
turtleUtils.digAll()
|
turtleUtils.digAll()
|
||||||
miner.robot.forward()
|
miner.robot.forward()
|
||||||
elseif robotState.dir == 'FORWARD' and robotState.z == targetZ then
|
elseif robotState.dir == 'FORWARD' and robotState.z == targetZ then
|
||||||
|
|||||||
@ -15,13 +15,13 @@ api.create = function()
|
|||||||
local incValue = 1
|
local incValue = 1
|
||||||
if isBackward then invValue = -1 end
|
if isBackward then invValue = -1 end
|
||||||
|
|
||||||
if dir == 'FORWARD' then
|
if state.dir == 'FORWARD' then
|
||||||
state.z = state.z + incValue
|
state.z = state.z + incValue
|
||||||
elseif dir == 'BACKWARD' then
|
elseif state.dir == 'BACKWARD' then
|
||||||
state.z = state.z - incValue
|
state.z = state.z - incValue
|
||||||
elseif dir == 'LEFT' then
|
elseif state.dir == 'LEFT' then
|
||||||
state.x = state.x - incValue
|
state.x = state.x - incValue
|
||||||
elseif dir == 'RIGHT' then
|
elseif state.dir == 'RIGHT' then
|
||||||
state.x = state.x + incValue
|
state.x = state.x + incValue
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user