diff --git a/remotedbserver.lua b/remotedbserver.lua index f275912..288820f 100644 --- a/remotedbserver.lua +++ b/remotedbserver.lua @@ -1,21 +1,16 @@ -if not fs.exists("data.db") then - local file = fs.open("data.db", "w") - file.write("{}") - file.close() -end -local file = fs.open("data.db","r+") local eplib = require("entrypointlib") -if not file then error("failed to open db file") end local function readTable() - file.seek("set") + local file = fs.open("data.db","r") + if not file then error("failed to open db file") end return textutils.unserialise(file.readAll() or "{}") or {} end local function writeTable(t) - file.seek("set") + local file = fs.open("data.db", "w") + if not file then error("failed to open db file") end file.write(textutils.serialise(t)) - file.flush() + file.close() end local function receive()