Advertisement
melzneni

TURTI_Storage

Oct 1st, 2021
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. Storage = {}
  2.  
  3. function Storage:new(path)
  4. local storage = {}
  5. setmetatable(storage, Storage)
  6. storage.__index = storage
  7. storage.path = path
  8. storage.data = {}
  9. return storage
  10. end
  11.  
  12. function Storage:write()
  13. local data = textutils.serialize(self.data)
  14. local f = fs.open(self.path, "w")
  15. f.write(data)
  16. f.close()
  17. end
  18.  
  19. function Storage:load()
  20. if fs.exists(self.path) then
  21. local f = fs.open(self.path, "r")
  22. f.readAll()
  23. f.close()
  24. return textutils.unserialize(data)
  25. end
  26. return {}
  27. end
  28.  
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement