Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if not fs.exists("/.persistence") then
- fs.makeDir("/.persistence")
- end
- function store(sName, stuff)
- local filePath = fs.combine("/.persistence", sName)
- if stuff == nil then
- return fs.delete(filePath)
- end
- local handle = fs.open(filePath, "w")
- handle.write(textutils.serialize(stuff))
- handle.close()
- end
- function pull(sName)
- local filePath = fs.combine("/.persistence", sName)
- if fs.exists(filePath) then
- local handle = fs.open(filePath, "r")
- local stuff = handle.readAll()
- handle.close()
- return textutils.unserialize(stuff)
- else
- return nil
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment