Page 1 of 3

A Saving Lib? [SOLVED]

Posted: Thu Apr 05, 2012 11:12 am
by Davidobot
Does know of a library which will allow me to save different variables and then load them up in the next game session. Eg: Save the level number, close the game, reopen, and you are still on the same level.

Re: A Saving Lib?

Posted: Thu Apr 05, 2012 1:55 pm
by trubblegum
What's wrong with love.filesystem?
Using something like TSerial, it's as simple as :

Code: Select all

local savedata = {...}
love.filesystem.write('save.sav', TSerial:pack(savedata))
local loaddata = TSerial:unpack(love.filesystem.read('save.sav'))

Re: A Saving Lib?

Posted: Thu Apr 05, 2012 2:21 pm
by Davidobot
trubblegum wrote:What's wrong with love.filesystem?
Using something like TSerial, it's as simple as :

Code: Select all

local savedata = {...}
love.filesystem.write('save.sav', TSerial:pack(savedata))
local loaddata = TSerial:unpack(love.filesystem.read('save.sav'))
Can you give me an example of a .love that uses this?

Re: A Saving Lib?

Posted: Thu Apr 05, 2012 2:33 pm
by TechnoCat

Re: A Saving Lib?

Posted: Thu Apr 05, 2012 2:45 pm
by Davidobot
Yes that is perfect for one variable, what about a whole bunch of them?

Re: A Saving Lib?

Posted: Thu Apr 05, 2012 2:53 pm
by kikito
You put all the variables into one single table, and save that.

Re: A Saving Lib?

Posted: Thu Apr 05, 2012 4:51 pm
by Davidobot
kikito wrote:You put all the variables into one single table, and save that.
I tried, but it gave me an error.

Re: A Saving Lib?

Posted: Thu Apr 05, 2012 5:28 pm
by Averice
Using json with loves filesystem does the trick for me.

Re: A Saving Lib?

Posted: Thu Apr 05, 2012 5:37 pm
by tsturzl
You can serialize your gamestate as is with DataDump, then save to a file.

Re: A Saving Lib?

Posted: Fri Apr 06, 2012 5:37 am
by Davidobot
Averice wrote:Using json with loves filesystem does the trick for me.
Json?