Changing move here to work with changes to move to.

This commit is contained in:
Harrison Deng 2021-05-09 14:20:32 -05:00
parent 9e9ea5dd2f
commit 68d94036cc
2 changed files with 10 additions and 6 deletions

View File

@ -19,7 +19,6 @@ local HEADING = "heading"
local QUARRY = "quarry"
local TASK = "task"
local FAILED = "failed"
-- Constant local actions
local MOVEHERE = "movehere"
-- Constant messsage types
local LOG = "LOG"
@ -87,9 +86,9 @@ local function listenForCommands()
elseif string.find(input, HEADING) == 1 then
sendDirective(LEADER, HEADING)
elseif string.find(input, MOVEHERE) == 1 then
local x,y,z = gps.locate()
local x, y, z = gps.locate()
y = y + 1
sendDirective(LEADER, MOVETO, x, y, z)
sendDirective(LEADER, MOVEHERE, x, y, z)
elseif string.find(input, QUARRY) == 1 then
deltasRaw = string.sub(input, string.len(QUARRY) + 1 + 1)
local deltas = captureString(deltasRaw, "([+-]?%d+)")

View File

@ -15,6 +15,7 @@ local HEADING = "heading"
local QUARRY = "quarry"
local TASK = "task"
local FAILED = "failed"
local MOVEHERE = "movehere"
-- Constant messaging
local LOG = "LOG"
local REQUEST = "REQ"
@ -387,7 +388,7 @@ local function moveTo(dest, relative)
dest = dest:round()
sendLog(MOVETO, "Attempting to move by (" .. dest.x .. "," .. dest.y .. "," .. dest.z .. ") (x,y,z).")
if position == nil or heading == nil then
if pos == nil or forward == nil then
sendLog(FAILED, "Position or heading is invalid.")
return
end
@ -445,7 +446,6 @@ local function moveTo(dest, relative)
end
end
local function quarry(x, y, z, relative, pattern)
x = tonumber(x)
y = tonumber(y)
@ -608,6 +608,11 @@ local function listen()
"\nPosition: " .. (status["position"]["coordinates"] and textutils.serialiseJSON(status["position"]) or "not positioned.") ..
"\nfuel: " .. tostring(status["fuel"]) ..
"\ncurrent task: " .. status["task"], status)
elseif data["request"] == MOVEHERE then
local x = data["content"][1]
local y = data["content"][2]
local z = data["content"][3]
moveTo(vector.new(x, y, z), false)
elseif data["request"] == POSITION then
determinePosition()
elseif data["request"] == HEADING then