From 8a21ae4d77cd9494348d9aa0045e3feb17e1b8e0 Mon Sep 17 00:00:00 2001 From: Harrison Deng Date: Fri, 7 May 2021 17:02:49 -0500 Subject: [PATCH] Basic quarrying implemented and untested. --- mineleader.lua | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/mineleader.lua b/mineleader.lua index 45d39e6..dbb663a 100644 --- a/mineleader.lua +++ b/mineleader.lua @@ -405,8 +405,26 @@ local function moveTo(dest) end -local function quarry(a, b) +local function quarry(x, y, z, forward, right, pattern) sendLog(QUARRY, "Starting quarry task from positions " .. tostring(a) .. " to " .. tostring(b) ".") + for yDelta=1,math.abs(y) do + for xDelta=1,math.abs(x) do + for zDelta=1,math.abs(z) do + orient(vector.new(0, 0, z), forward, right) + attemptBreakUp(pattern) + attemptBreakDown(pattern) + attemptBreakFront(pattern) + attemptMoveForward() + end + orient(vector.new(x, 0, 0), forward, right) + attemptMoveForward() + end + if (y > 0) { + attemptMoveUp(); + } elseif (y < 0) { + attemptMoveDown(); + } + end end local function executeTasks() @@ -495,6 +513,11 @@ local function listen() elseif data["request"] == HEADING then determineHeading() elseif data["request"] == QUARRY then + if heading ~= nil then + quarry(data["content"][1], data["content"][2], data["content"][3], heading, rightAxis) + else + quarry(data["content"][1], data["content"][2], data["content"][3], relHeading, relRightAxis) + end end end end