Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Storage = {}
- function Storage:new(path)
- local storage = {}
- setmetatable(storage, Storage)
- storage.__index = storage
- storage.path = path
- storage.data = {}
- return storage
- end
- function Storage:write()
- local data = textutils.serialize(self.data)
- local f = fs.open(self.path, "w")
- f.write(data)
- f.close()
- end
- function Storage:load()
- if fs.exists(self.path) then
- local f = fs.open(self.path, "r")
- f.readAll()
- f.close()
- return textutils.unserialize(data)
- end
- return {}
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement