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

Save/Load System Help

Post by sheaflower98 » Thu Apr 04, 2019 5:24 pm

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!

Party member
Posts: 121
Joined: Sun Feb 14, 2016 1:13 pm

Re: Save/Load System Help

Post by steVeRoll » Thu Apr 04, 2019 8:46 pm

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 ="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
Inner party member
Posts: 820
Joined: Sat Dec 10, 2011 7:18 pm

Re: Save/Load System Help

Post by veethree » Thu Apr 04, 2019 8:56 pm

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: No registered users and 35 guests