Jupiter - Save tables to files
Posted: Tue Sep 18, 2012 8:18 pm
Hello. I know you guys like to gets your hands on libraries so I spent a little time abstracting some of my code into one. It's a file i/o library, so I called it Jupiter (Io is one of its moons...). If you dislike the name, it matters not!
The above script would generate the following file in the love.filesystem.getSaveDirectory folder:
Nested tables manifest as:
https://github.com/Lafolie/Jupiter
Have fun saving your data.
Code: Select all
jupiter = require "jupiter"
data = {_fileName = "example.txt", "Save this string!"}
success = jupiter.save(data)
newData = jupiter.load("filename.extension")
Jupiter is capable of handling nested tables to the nth degree, so it will serialise and write your tables to a file for you. To keep things simple Jupiter handles filenames of loaded files for you. However, if you are writing a new file you must include the table property _fileName in the lowest level of your table:example.txt wrote: 1=Save this string
Code: Select all
tableToSave = {_fileName = "example.txt", someVar = 7}
Full documentation and the script itself can be found on github:some.file wrote: index.subIndex.nIndex=value
https://github.com/Lafolie/Jupiter
Have fun saving your data.