From 09fc50d55e22ca00a332b835b92a2f2a7807cd2f Mon Sep 17 00:00:00 2001 From: Guillaume ARM Date: Wed, 8 May 2024 22:57:37 +0200 Subject: [PATCH] fix: keep track of current miner targetY --- miner.lua | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/miner.lua b/miner.lua index 044f078..1e4102a 100644 --- a/miner.lua +++ b/miner.lua @@ -4,16 +4,16 @@ local turtleUtils = require('turtle-utils') local config = { startY = 122, targetY = 109, - height = 1, + height = 3, size = 4 } -local TARGET_Y = config.targetY - config.startY +local INITIAL_TARGET_Y = config.targetY - config.startY local TARGET_Z = config.size - 1 local TARGET_X = config.size - 1 local MAX_X = TARGET_X -local MAX_Y = TARGET_Y + (config.height - 1) +local MAX_Y = INITIAL_TARGET_Y + (config.height - 1) local MAX_Z = TARGET_Z local LOWER_LIMIT = 2; @@ -23,13 +23,14 @@ local robot = robotApi.create() local MAX_INVENTORY_BLOCKS = 16 * 64 local ADDITIONAL_FUEL_NEEDED = 128 -local MIN_FUEL_NEEDED = (config.size * 2) + TARGET_Y + MAX_INVENTORY_BLOCKS + ADDITIONAL_FUEL_NEEDED +local MIN_FUEL_NEEDED = (config.size * 2) + INITIAL_TARGET_Y + MAX_INVENTORY_BLOCKS + ADDITIONAL_FUEL_NEEDED local miner = { robot = robot, mission = 'unload', -- "unload" | "refuel" | "mine" | "return-home" | "return-mine" | nil finished = false, - lastPositionState = nil -- { x, y, z, dir } + lastPositionState = nil, -- { x, y, z, dir } + targetY = INITIAL_TARGET_Y } local function isOdd(x) @@ -140,7 +141,7 @@ end local function mineProcedure() local robotState = miner.robot.getState() - local targetY = TARGET_Y + local targetY = miner.targetY local targetZ = TARGET_Z -- 1. Move @@ -181,6 +182,7 @@ local function mineProcedure() miner.robot.turnRight() miner.robot.up() + miner.targetY = miner.targetY - 1 end if turtleUtils.countFreeSlots() < 1 then