Jupiter - Save tables to files

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Jupiter - Save tables to files

Post 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.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
luaz
Citizen
Posts: 83
Joined: Sun Sep 16, 2012 2:55 pm

Re: Jupiter - Save tables to files

Post by luaz »

Nice! I may use this thing when I get past all the main menus and stuff. :awesome:
If you're going to reply to my post, consider posting an (preferably working) example - 99.7% of time time, I already know how to implement the feature theoretically! ;) I don't learn very well from references, etc....
Anickyan
Prole
Posts: 27
Joined: Sun Aug 05, 2012 8:42 am

Re: Jupiter - Save tables to files

Post 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
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Jupiter - Save tables to files

Post by Lafolie »

You're joking right?
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Jupiter - Save tables to files

Post by Robin »

Lafolie wrote:You're joking right?
Lord I hope so.
Help us help you: attach a .love.
Anickyan
Prole
Posts: 27
Joined: Sun Aug 05, 2012 8:42 am

Re: Jupiter - Save tables to files

Post 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.
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: Jupiter - Save tables to files

Post by Roland_Yonaba »

luaz
Citizen
Posts: 83
Joined: Sun Sep 16, 2012 2:55 pm

Re: Jupiter - Save tables to files

Post by luaz »

:huh:
Anickyan wrote:I see that it easily looks like something else.
:o
If you're going to reply to my post, consider posting an (preferably working) example - 99.7% of time time, I already know how to implement the feature theoretically! ;) I don't learn very well from references, etc....
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests