Page 1 of 1

Jupiter - Save tables to files

Posted: Tue Sep 18, 2012 8:18 pm
by Lafolie
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!

Code: Select all

jupiter = require "jupiter"
data = {_fileName = "example.txt", "Save this string!"}
success = jupiter.save(data)
newData = jupiter.load("filename.extension")
The above script would generate the following file in the love.filesystem.getSaveDirectory folder:
example.txt wrote: 1=Save this string
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:

Code: Select all

tableToSave = {_fileName = "example.txt", someVar = 7}
Nested tables manifest as:
some.file wrote: index.subIndex.nIndex=value
Full documentation and the script itself can be found on github:

https://github.com/Lafolie/Jupiter

Have fun saving your data.

Re: Jupiter - Save tables to files

Posted: Wed Sep 26, 2012 10:17 pm
by luaz
Nice! I may use this thing when I get past all the main menus and stuff. :awesome:

Re: Jupiter - Save tables to files

Posted: Thu Sep 27, 2012 5:36 pm
by Anickyan
Nice. But I think you over-complicated the table saving/loading WAAAAY too much. Look at this (at the bottom of the code), and see if you can figure out what I did... :D

Re: Jupiter - Save tables to files

Posted: Thu Sep 27, 2012 6:47 pm
by Lafolie
You're joking right?

Re: Jupiter - Save tables to files

Posted: Fri Sep 28, 2012 10:55 am
by Robin
Lafolie wrote:You're joking right?
Lord I hope so.

Re: Jupiter - Save tables to files

Posted: Fri Sep 28, 2012 11:04 am
by Anickyan
I know that it sounded like whoring, but it was not meant to do that, at all. I was just trying to tell you, that I thought you overcomplicated it. I see that it easily looks like something else.

Re: Jupiter - Save tables to files

Posted: Fri Sep 28, 2012 11:49 am
by Roland_Yonaba

Re: Jupiter - Save tables to files

Posted: Fri Sep 28, 2012 8:07 pm
by luaz
:huh:
Anickyan wrote:I see that it easily looks like something else.
:o