fix(robot-api): mutateRobotPosition

This commit is contained in:
Guillaume ARM 2024-05-08 22:13:53 +02:00
parent 1b3a46e608
commit f75f280193
2 changed files with 5 additions and 12 deletions

View File

@ -145,16 +145,9 @@ local function mineProcedure()
-- 1. Move
if robotState.y > targetY then
local ok, err = turtle.digDown()
if not ok then
error('Cannot dig down because ' .. err)
end
turtle.digDown()
miner.robot.down()
elseif robotState.dir == 'FORWARD' and robotState.z < targetZ then
-- TODO: remove this print (debug purpose)
print(robotState.z, targetZ)
turtleUtils.digAll()
miner.robot.forward()
elseif robotState.dir == 'FORWARD' and robotState.z == targetZ then

View File

@ -15,13 +15,13 @@ api.create = function()
local incValue = 1
if isBackward then invValue = -1 end
if dir == 'FORWARD' then
if state.dir == 'FORWARD' then
state.z = state.z + incValue
elseif dir == 'BACKWARD' then
elseif state.dir == 'BACKWARD' then
state.z = state.z - incValue
elseif dir == 'LEFT' then
elseif state.dir == 'LEFT' then
state.x = state.x - incValue
elseif dir == 'RIGHT' then
elseif state.dir == 'RIGHT' then
state.x = state.x + incValue
end
end