Fixed syntax error
This commit is contained in:
20
core.lua
20
core.lua
@@ -43,19 +43,21 @@ function Core:read()
|
||||
if not self then
|
||||
error("No instance!")
|
||||
end
|
||||
|
||||
|
||||
if not self.ws then
|
||||
return false, "Websocket not initiated";
|
||||
end
|
||||
|
||||
return true, textutils.unserialiseJSON(self.ws.receive())
|
||||
local data, success = self.ws.receive()
|
||||
|
||||
return true, textutils.unserialiseJSON(data)
|
||||
end
|
||||
|
||||
function Core:download(file)
|
||||
if not self then
|
||||
error("No instance!")
|
||||
end
|
||||
|
||||
|
||||
if not self.ws then
|
||||
return false, "Websocket not initiated";
|
||||
end
|
||||
@@ -65,15 +67,15 @@ function Core:download(file)
|
||||
local success, data = self:read();
|
||||
|
||||
if not success then
|
||||
return false, "Failed to read: "+data;
|
||||
return false, "Failed to read: "..data;
|
||||
end
|
||||
|
||||
if not data.type then
|
||||
return false, "Invalid package: "+textutils.serialiseJSON(data);
|
||||
return false, "Invalid package: "..textutils.serialiseJSON(data);
|
||||
end
|
||||
|
||||
if not (data.type == "FILE_INFO") then
|
||||
return false, "Invalid package type: "+textutils.serialiseJSON(data);
|
||||
return false, "Invalid package type: "..textutils.serialiseJSON(data);
|
||||
end
|
||||
|
||||
if not data.exists then
|
||||
@@ -85,15 +87,15 @@ function Core:download(file)
|
||||
local success, data = self:read();
|
||||
|
||||
if not success then
|
||||
return false, "Failed to read: "+data;
|
||||
return false, "Failed to read: "..data;
|
||||
end
|
||||
|
||||
if not data.type then
|
||||
return false, "Invalid package: "+textutils.serialiseJSON(data);
|
||||
return false, "Invalid package: "..textutils.serialiseJSON(data);
|
||||
end
|
||||
|
||||
if not data.type == "FILE_DATA" then
|
||||
return false, "Invalid type: "+textutils.serialiseJSON(data)
|
||||
return false, "Invalid type: "..textutils.serialiseJSON(data)
|
||||
end
|
||||
|
||||
local fileStream = io.open(file, "w");
|
||||
|
||||
Reference in New Issue
Block a user