From f75f280193087f2ffd771fbcce449774940188cb Mon Sep 17 00:00:00 2001 From: Guillaume ARM Date: Wed, 8 May 2024 22:13:53 +0200 Subject: [PATCH] fix(robot-api): mutateRobotPosition --- miner.lua | 9 +-------- robot.lua | 8 ++++---- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/miner.lua b/miner.lua index e6491a1..fd21e0f 100644 --- a/miner.lua +++ b/miner.lua @@ -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 diff --git a/robot.lua b/robot.lua index 02d44e0..d2e1942 100644 --- a/robot.lua +++ b/robot.lua @@ -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