Compare commits

...

1 Commits

Author SHA1 Message Date
a2494b11b0 wip persistent storage 2025-12-24 12:55:15 -08:00
4 changed files with 3628 additions and 1 deletions

File diff suppressed because one or more lines are too long

3605
libs/deflate.lua Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,22 @@
local id = ...
local deflate = dofile("libs/deflate.lua")
local filepath = fs.combine("/persisted-data",id)
local expect = dofile("rom/modules/main/cc/expect.lua")
local expect, field = expect.expect, expect.field
local lib={}
function lib.load()
if fs.exists(filepath) then
local file = fs.open(filepath,"r")
local data = textutils.unserialise(deflate:DecompressDeflate(file.readAll()))
file.close()
return data
else
return {}
end
end
function lib.save(data)
expect(1,data,"table")
local file = fs.open(filepath,"w")
file.write(deflate:CompressDeflate(textutils.serialise(data),{level=8}))
end
return lib