Changing move here to work with changes to move to.
This commit is contained in:
parent
9e9ea5dd2f
commit
68d94036cc
@ -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+)")
|
||||
|
@ -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
|
||||
@ -419,7 +420,7 @@ local function moveTo(dest, relative)
|
||||
end
|
||||
xblocked = not attemptMoveForward()
|
||||
end
|
||||
|
||||
|
||||
if position.y ~= dest.y then
|
||||
if dest.y - pos.y > 0 then
|
||||
yBlocked = not attemptMoveUp()
|
||||
@ -444,7 +445,6 @@ local function moveTo(dest, relative)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function quarry(x, y, z, relative, pattern)
|
||||
x = tonumber(x)
|
||||
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user