Save/Load System Help

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.
Post Reply
sheaflower98
Prole
Posts: 1
Joined: Thu Apr 04, 2019 4:33 pm

Save/Load System Help

Post by sheaflower98 »

I am not entirely sure how to implement a save/load system to my game. I've searched through LOVE's documentation but it doesn't really go into much detail for that, and searching the forums isn't very helpful either since it basically just gives me EVERYTHING with the words save, load or system and I can't really sift through all that to find what I need. I'm a complete beginner to this so try to make it as simple as you can? Please and thank you for the help!
User avatar
steVeRoll
Party member
Posts: 131
Joined: Sun Feb 14, 2016 1:13 pm

Re: Save/Load System Help

Post by steVeRoll »

Hi and welcome to the forums!
If you want to save something to the player's computer, it involves writing to a file. When you want to load that data, you read the file.
In löve, writing to a file is as simple as:

Code: Select all

love.filesystem.write("filename.txt", "abcd 1234 some data here")
And if you want to read it:

Code: Select all

data = love.filesystem.read("filename.txt")
print(data) -- will output whatever you wrote previously
Of course, whatever you write and how you read it is entirely up to you.
User avatar
veethree
Inner party member
Posts: 875
Joined: Sat Dec 10, 2011 7:18 pm

Re: Save/Load System Help

Post by veethree »

Writing data to a file is simple, The trickier part is how to structure the data.

You could use something like a csv or ini file, But considering your dealing with lua, I'd suggest learning about table serialization.

Table serialization basically converts lua tables into strings that you can write to a file, then later you deserialize it to convert the string back into a table.

You could write your own functions to do this, Or you could use a library such as bitser.
Post Reply

Who is online

Users browsing this forum: Google [Bot], rabbitboots and 67 guests