druidbruce

AEst tablePersistence

Apr 25th, 2016
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. function load(file)
  2. local loaded = nil
  3.  
  4. if fs.exists(file) then
  5. local fh = fs.open(file, "r")
  6. local s = fh.readAll()
  7. loaded = textutils.unserialize(s)
  8. fh.close()
  9. end
  10.  
  11. return loaded
  12. end
  13.  
  14. function save(file, value)
  15. local fh = fs.open(file, "w")
  16. fh.write(textutils.serialize(value))
  17. fh.close()
  18. end
Add Comment
Please, Sign In to add comment