Fixed incorrect table fields being referenced.

This commit is contained in:
Harrison Deng 2021-05-03 14:21:07 -05:00
parent 40ff22f327
commit d0ba5a96de

View File

@ -327,10 +327,10 @@ local function listen()
local event, side, sendChannel, replyChannel, serialized, distance = os.pullEvent("modem_message")
print("Recieved data...")
local data = textutils.unserialise(serialized)
if data["token"] == TOKEN and data["recipient"] == UNIT then
print("Got content: " .. data["type"])
if data["token"] == TOKEN and data["recipient"] == UNIT and data["type"] == REQUEST then
print("Got request: " .. data["request"])
if data["type"] == LUA_PREFIX then
if data["request"] == LUA_PREFIX then
print("Executing: " .. data["content"][0])
local f = loadstring(luaScript)
if f ~= nil then
@ -342,7 +342,7 @@ local function listen()
else
printError("Unable to load lua string.")
end
elseif data["type"] == MOVETO then
elseif data["request"] == MOVETO then
local x = data["content"][1]
local y = data["content"][2]
local z = data["content"][3]
@ -355,7 +355,7 @@ local function listen()
sendLog(MOVETO, "Using relative coordinates to move.")
attemptStartTask(moveTo, vector.new(x,y,z), relHeading, relRightAxis)
end
elseif data["type"] == MOVEBY then
elseif data["request"] == MOVEBY then
local x = data["content"][1]
local y = data["content"][2]
local z = data["content"][3]
@ -368,7 +368,7 @@ local function listen()
sendLog(MOVEBY, "Using relative coordinates to move.")
attemptStartTask(moveBy, vector.new(x,y,z), relHeading, relRightAxis)
end
elseif data["type"] == STATUS then
elseif data["request"] == STATUS then
status = {
relative_position = {
coordinates=relativePos,
@ -383,11 +383,11 @@ local function listen()
fuel=turtle.getFuelLevel(),
}
sendLog(STATUS, status)
elseif string.find(content, POSITION) == 1 then
elseif data["request"] == POSITION then
locatePosition()
elseif string.find(content, HEADING) == 1 then
elseif data["request"] == HEADING then
determineHeading()
elseif string.find(content, QUARRY) == 1 then
elseif data["request"] == QUARRY then
end
end
end