iNxmi

serial.lua

Nov 7th, 2023
1,315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.42 KB | Gaming | 0 0
  1. function loadTableFromFile(path)
  2.     local file = fs.open(path, "r")
  3.     local table = textutils.unserialize(file.readAll())
  4.     file.close()
  5.    
  6.     return table
  7. end
  8.  
  9. function saveTableAsFile(path, table)
  10.     local file = fs.open(path, "w")
  11.     local data = textutils.serialize(table)
  12.     file.write(data)
  13.     file.close()
  14. end
  15.  
  16. return {
  17.     loadTableFromFile = loadTableFromFile,
  18.     saveTableAsFile = saveTableAsFile
  19. }
Advertisement
Add Comment
Please, Sign In to add comment