Scoreboard question
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Periwasmarkedasspam
- Prole
- Posts: 9
- Joined: Sun Feb 08, 2015 5:30 am
Scoreboard question
Hello, im trying to add a scoreboard, but i dont know how to store values on a table permanently. How can i do this?
Re: Scoreboard question
Take a look at Robin's "ser" library which can serialize the table to a string.
Then you save that string to a file and "require" it next time you run the game.
Then you save that string to a file and "require" it next time you run the game.
- Periwasmarkedasspam
- Prole
- Posts: 9
- Joined: Sun Feb 08, 2015 5:30 am
Re: Scoreboard question
I dont know how this work... Can someone show me how it works?
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Scoreboard question
In this case, you'd probably want to download Ser and do something like:
Code: Select all
local serialize = require 'ser'
function love.load()
local ok, chunk = pcall(love.filesystem.load, 'highscores.lua')
if ok then
highscores = chunk()
else
highscores = {}
end
end
function love.quit()
love.filesystem.write('highscores.lua', serialize(highscores))
end
Help us help you: attach a .love.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], darkfrei and 3 guests