pandorrama

tableToFile

Sep 9th, 2020
888
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local serialization = require("serialization")
  2.  
  3. local tableToFile = {}
  4.  
  5. function tableToFile.load(location)
  6.   --returns a table stored in a file.
  7.   local tableFile = assert(io.open(location))
  8.   return serialization.unserialize(tableFile:read("*all"))
  9. end
  10.  
  11. function tableToFile.save(table, location)
  12.   --saves a table to a file
  13.   local tableFile = assert(io.open(location, "w"))
  14.   tableFile:write(serialization.serialize(table))
  15.   tableFile:close()
  16. end
  17.  
  18. return tableToFile
RAW Paste Data