A Saving Lib? [SOLVED]

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

A Saving Lib? [SOLVED]

Post 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.
Last edited by Davidobot on Fri Apr 06, 2012 4:06 pm, edited 1 time in total.
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
trubblegum
Party member
Posts: 192
Joined: Wed Feb 22, 2012 10:40 pm

Re: A Saving Lib?

Post 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'))
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: A Saving Lib?

Post 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?
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Milwaukee, WI
Contact:

Re: A Saving Lib?

Post by TechnoCat »

User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: A Saving Lib?

Post by Davidobot »

Yes that is perfect for one variable, what about a whole bunch of them?
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: A Saving Lib?

Post by kikito »

You put all the variables into one single table, and save that.
When I write def I mean function.
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: A Saving Lib?

Post by Davidobot »

kikito wrote:You put all the variables into one single table, and save that.
I tried, but it gave me an error.
Attachments
Dungeon Crawler.love
(17.86 KiB) Downloaded 161 times
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
Averice
Prole
Posts: 25
Joined: Thu Apr 05, 2012 5:20 pm

Re: A Saving Lib?

Post by Averice »

Using json with loves filesystem does the trick for me.
User avatar
tsturzl
Party member
Posts: 161
Joined: Fri Apr 08, 2011 3:24 am

Re: A Saving Lib?

Post by tsturzl »

You can serialize your gamestate as is with DataDump, then save to a file.
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: A Saving Lib?

Post by Davidobot »

Averice wrote:Using json with loves filesystem does the trick for me.
Json?
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 9 guests