Page 1 of 1
Save/Load System Help
Posted: Thu Apr 04, 2019 5:24 pm
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!
Re: Save/Load System Help
Posted: Thu Apr 04, 2019 8:46 pm
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.
Re: Save/Load System Help
Posted: Thu Apr 04, 2019 8:56 pm
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.