Added check to see if unserializing is necessary.

This commit is contained in:
Harrison Deng 2021-05-03 18:23:53 -05:00
parent 6f94e81ca1
commit e6d75af1f7

View File

@ -425,7 +425,11 @@ local function listen()
print("Listening for directives...")
local event, side, sendChannel, replyChannel, serialized, distance = os.pullEvent("modem_message")
print("Recieved data...")
local data = textutils.unserialise(serialized)
local data = nil
if not pcall(function() data = textutils.unserialise(serialized) end) then
print("Message already table, not deserializing.")
data = serialized
end
if data["token"] == TOKEN and data["recipient"] == UNIT and data["type"] == REQUEST then
print("Got request: " .. data["request"])