Highscöre - easy highscore functions

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
Tesselode
Party member
Posts: 555
Joined: Fri Jul 23, 2010 7:55 pm

Highscöre - easy highscore functions

Post by Tesselode »

Well I decided I would need one of these, so why not release one?

These are just a few functions for making simple, text-based highscore tables. Since I couldn't find any other ones. And yes I tested them.

Download:
http://tesselode.110mb.com/love_highscore_functions.zip



BASIC USAGE:
First of all, always remember to use love.filesystem.setIdentity().
You'll also need to execute the following code somewhere before you use this:

Code: Select all

require "path/to/highscore.lua"
...if you didn't already know that.

Then you can start calling functions:

Code: Select all

highscore_new(filename, places, name, score)
Use this to create a blank highscore table if you don't already have one. Filename is the name of the file where the highscore table is stored. Places is the number of places in the highscore table. Name is the placeholder name for places nobody has taken yet, and score is the placeholder score.

Code: Select all

highscore_load(filename)
Loads the high scores from file filename. Always use this before trying to use highscore_write() or highscore_add()! By the way, this function stores the high scores in the variables highscore and highscore_name. And it also uses highscore_places, so don't try to use that variable.

Code: Select all

highscore_write(filename)
Writes the currently stored high scores to the file filename. You'll probably want to use this after using highscore_add().

Code: Select all

highscore_add(score, name)
Enters the score score into the highscore table, as well as the corresponding name.



Well that's it; 4 functions. Hopefully you will be able to make good use of this. If you find any way to improve this or find any bugs, go ahead and tell me.
Last edited by Tesselode on Thu Jul 29, 2010 9:58 pm, edited 1 time in total.
User avatar
Felipe Budinich
Citizen
Posts: 67
Joined: Thu Jul 29, 2010 1:36 pm

Re: Highscöre - easy highscore functions

Post by Felipe Budinich »

Neat, thanks :-)
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Highscöre - easy highscore functions

Post by Robin »

It would be cleaner to use return values and function arguments rather than global variables. Other than that, neat! :)
Help us help you: attach a .love.
User avatar
Tesselode
Party member
Posts: 555
Joined: Fri Jul 23, 2010 7:55 pm

Re: Highscöre - easy highscore functions

Post by Tesselode »

Do you think this counts as a library? And should I add it to the wiki?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Highscöre - easy highscore functions

Post by Robin »

Tesselode wrote:Do you think this counts as a library? And should I add it to the wiki?
Libraries don't have to be Alexandrian to count, so yeah, go ahead.
Help us help you: attach a .love.
User avatar
Tesselode
Party member
Posts: 555
Joined: Fri Jul 23, 2010 7:55 pm

Re: Highscöre - easy highscore functions

Post by Tesselode »

OK, I added it. I hope I did it right. Feel free to edit the heck out of it.
Post Reply

Who is online

Users browsing this forum: No registered users and 60 guests