Code: Select all
12, 30
Code: Select all
player.x, player,y = love.filesystem.read("SaveData")
Code: Select all
12, 30
Code: Select all
player.x, player,y = love.filesystem.read("SaveData")
You can read data into 1 variable and parse it via lua's string library using pattern matching.NoreoAlles wrote: ↑Thu May 19, 2022 7:02 pm Hey, i know the thread beneath me is about a similar topic and i already asked something like this, but i just want to know, how i can read a save file with something like this in it:and read it with the love.filesystem stuff so i could use it like thisCode: Select all
12, 30
ThanksCode: Select all
player.x, player,y = love.filesystem.read("SaveData")
Code: Select all
player.x, player.y = love.filesystem.read("SaveData"):match("(%d+).(%d+)")
And why is that? It really does not matter as long as the input and the parser respect the same formatting rules. You can use any character for separating values such as pipe, semicolon, tabs etc. Completely up to you.
Thanks, will try!GVovkiv wrote: ↑Thu May 19, 2022 7:33 pmYou can read data into 1 variable and parse it via lua's string library using pattern matching.NoreoAlles wrote: ↑Thu May 19, 2022 7:02 pm Hey, i know the thread beneath me is about a similar topic and i already asked something like this, but i just want to know, how i can read a save file with something like this in it:and read it with the love.filesystem stuff so i could use it like thisCode: Select all
12, 30
ThanksCode: Select all
player.x, player,y = love.filesystem.read("SaveData")
You can place every peace of data on new line and read it with https://love2d.org/wiki/love.filesystem.lines.
You might use some file format and users made library for that.
(In your case, it seems that CSV https://en.wikipedia.org/wiki/Comma-separated_values will suit you well;
quick google search show me https://github.com/geoffleyland/lua-csv as first lua CSV lib on github, so you might try it.)
Users browsing this forum: No registered users and 150 guests