Fixed heading print response and removed parsing status parsing from host.
This commit is contained in:
parent
d95cae9caf
commit
5a784bc23b
@ -100,12 +100,6 @@ local function handleMessage(sender, type, data)
|
|||||||
|
|
||||||
if type == LOG then
|
if type == LOG then
|
||||||
print("[" .. sender .. "]: " .. data["log"] .. ": " .. (data["content"]["n"] >= 1 and tostring(data["content"][1]) or ""))
|
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
|
elseif type == REQUEST then
|
||||||
handleRequest(sender, data["request"], data["content"])
|
handleRequest(sender, data["request"], data["content"])
|
||||||
end
|
end
|
||||||
|
@ -274,6 +274,7 @@ local function determineHeading()
|
|||||||
end
|
end
|
||||||
heading = fDelta
|
heading = fDelta
|
||||||
rightAxis = position - oldPos
|
rightAxis = position - oldPos
|
||||||
|
rightAxis = vector.new(rightAxis.x, rightAxis.y, rightAxis.z)
|
||||||
sendLog(HEADING, "Heading obtained. \nForward: " .. heading .. "\nRight direction: " .. rightAxis)
|
sendLog(HEADING, "Heading obtained. \nForward: " .. heading .. "\nRight direction: " .. rightAxis)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -384,7 +385,10 @@ local function listen()
|
|||||||
fuel=turtle.getFuelLevel(),
|
fuel=turtle.getFuelLevel(),
|
||||||
task=(task and task["name"] or "nothing")
|
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
|
elseif data["request"] == POSITION then
|
||||||
locatePosition()
|
locatePosition()
|
||||||
elseif data["request"] == HEADING then
|
elseif data["request"] == HEADING then
|
||||||
|
Loading…
Reference in New Issue
Block a user