Save/Load System Help
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 1
- Joined: Thu Apr 04, 2019 4:33 pm
Save/Load System Help
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
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:
And if you want to read it:
Of course, whatever you write and how you read it is entirely up to you.
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")
Code: Select all
data = love.filesystem.read("filename.txt")
print(data) -- will output whatever you wrote previously
Re: Save/Load System Help
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.
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.
Who is online
Users browsing this forum: Google [Bot] and 4 guests