diff --git a/minehost.lua b/minehost.lua index cd404ac..8697e1f 100644 --- a/minehost.lua +++ b/minehost.lua @@ -16,7 +16,7 @@ local MOVETO = "moveto" local STATUS = "status" local POSITION = "position" local HEADING = "heading" -local QUARRYCHUNK = "quarry" +local QUARRY = "quarry" local TASK = "task" local FAILED = "failed" -- Constant local actions @@ -92,6 +92,10 @@ local function listenForCommands() local x,y,z = gps.locate() y = y + 1 sendDirective(LEADER, MOVETO, x, y, z) + elseif string.find(input, QUARRY) == 1 then + deltasRaw = string.sub(input, string.len(QUARRY) + 1 + 1) + local deltas = captureString(coordsRaw, "([+-]?%d+)") + sendDirective(LEADER, QUARRY, deltas[1], deltas[2], deltas[3]) end end end diff --git a/mineleader.lua b/mineleader.lua index 98035e4..182415c 100644 --- a/mineleader.lua +++ b/mineleader.lua @@ -12,7 +12,7 @@ local MOVETO = "moveto" local STATUS = "status" local POSITION = "position" local HEADING = "heading" -local QUARRYCHUNK = "quarry" +local QUARRY = "quarry" local TASK = "task" local FAILED = "failed" -- Constant messaging @@ -421,8 +421,10 @@ local function quarry(x, y, z, forward, right, pattern) end if (y > 0) then attemptMoveUp(); - elseif (y < 0) then - attemptMoveDown(); + else + if not attemptMoveDown() then + sendLog(FAILED, "Unable to move further down for quarrying.") + end end end end @@ -515,7 +517,9 @@ local function listen() elseif data["request"] == QUARRY then if heading ~= nil then quarry(data["content"][1], data["content"][2], data["content"][3], heading, rightAxis) + sendLog(QUARRY, "Using actual position for quarrying.") else + sendLog(QUARRY, "Using relative position for quarrying.") quarry(data["content"][1], data["content"][2], data["content"][3], relHeading, relRightAxis) end end