Added host side command for quarrying.

This commit is contained in:
Harrison Deng 2021-05-07 17:10:41 -05:00
parent ced8bc2b50
commit 25f5c4a62b
2 changed files with 12 additions and 4 deletions

View File

@ -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

View File

@ -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