Fixed heading print response and removed parsing status parsing from host.

This commit is contained in:
Harrison Deng 2021-05-03 15:41:09 -05:00
parent d95cae9caf
commit 5a784bc23b
2 changed files with 5 additions and 7 deletions

View File

@ -100,12 +100,6 @@ local function handleMessage(sender, type, data)
if type == LOG then
print("[" .. sender .. "]: " .. data["log"] .. ": " .. (data["content"]["n"] >= 1 and tostring(data["content"][1]) or ""))
if data["log"] == STATUS then
print("Relative position: " .. textutils.serializeJSON(data["content"][1]["relative_position"]))
print("Position: " .. (data["content"][1]["position"]["coordinates"] and textutils.serialiseJSON(data["content"][1]["position"]) or "not positioned."))
print("fuel: " .. tostring(data["content"][1]["fuel"]))
print("current task: " .. data["content"][1]["task"])
end
elseif type == REQUEST then
handleRequest(sender, data["request"], data["content"])
end

View File

@ -274,6 +274,7 @@ local function determineHeading()
end
heading = fDelta
rightAxis = position - oldPos
rightAxis = vector.new(rightAxis.x, rightAxis.y, rightAxis.z)
sendLog(HEADING, "Heading obtained. \nForward: " .. heading .. "\nRight direction: " .. rightAxis)
end
@ -384,7 +385,10 @@ local function listen()
fuel=turtle.getFuelLevel(),
task=(task and task["name"] or "nothing")
}
sendLog(STATUS, status)
sendLog(STATUS, "Relative position: " .. textutils.serializeJSON(data["content"][1]["relative_position"]) ..
"\nPosition: " .. (data["content"][1]["position"]["coordinates"] and textutils.serialiseJSON(data["content"][1]["position"]) or "not positioned.") ..
"\nfuel: " .. tostring(data["content"][1]["fuel"]) ..
"\ncurrent task: " .. data["content"][1]["task"], status)
elseif data["request"] == POSITION then
locatePosition()
elseif data["request"] == HEADING then