Update remotedbserver.lua
This commit is contained in:
@@ -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")
|
local eplib = require("entrypointlib")
|
||||||
if not file then error("failed to open db file") end
|
|
||||||
|
|
||||||
local function readTable()
|
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 {}
|
return textutils.unserialise(file.readAll() or "{}") or {}
|
||||||
end
|
end
|
||||||
|
|
||||||
local function writeTable(t)
|
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.write(textutils.serialise(t))
|
||||||
file.flush()
|
file.close()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function receive()
|
local function receive()
|
||||||
|
|||||||
Reference in New Issue
Block a user