[Library] BeTR: Best Time Recorder

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
.InsertNameHere
Prole
Posts: 9
Joined: Mon May 18, 2015 6:53 am

[Library] BeTR: Best Time Recorder

Post by .InsertNameHere »

This is a highscores library for times. Great for games or applications that want to monitor the best time

As of v1.0, BeTR only records the #1 best time, but I am trying to add more.

Im sure this is probably not the cleanest code or best library, but I'm still a beginner, and it works for the small games I am programming.

I'm also new to Github and all that, so the page might be formatted right either. Anyway, here is the github page: https://github.com/1nsertNameHere/BeTR

How to use it:

Code: Select all

besttime.path(path) - defines file for best time   - recommend being placed in love.load (This file is in applications support, the path is 		      basically just the name you want)
besttime.start() - creates file for best time      - recommend being placed in love.load
besttime.new(time) - checks if time is lower than current best, then adds
besttime.get() - returns the best time
besttime.reset() - sets best back to 9999
besttime.set(time) - FORCES this new time to be set
	good for if you're using this for a highscore and not a best time
	(you probably want to edit the starting number from 9999 then though)
Note that while this is not yet in the readme.mt (jsut ignore that), it is in the library code itself.

Please commend suggestions, bugs, or edits!
Last edited by .InsertNameHere on Sat Jun 06, 2015 10:54 pm, edited 1 time in total.
User avatar
veethree
Inner party member
Posts: 877
Joined: Sat Dec 10, 2011 7:18 pm

Re: [Library] BeTR: Best Time Recorder

Post by veethree »

It's recommended to keep your library out of the global scope. Make besttime local, then return it at the bottom. That way the user can call it whatever he wants by doing

Code: Select all

something = require "best_times"
Also in besttime.path() you define a global variable called "path", I'd recommend renaming the function or the variable and putting it into the besttime table isntead

Code: Select all

function besttime.path(ans)
	 besttime.filePath = ans
end
or

Code: Select all

function besttime.setPath(ans)
	 besttime.path = ans
end
.InsertNameHere
Prole
Posts: 9
Joined: Mon May 18, 2015 6:53 am

Re: [Library] BeTR: Best Time Recorder

Post by .InsertNameHere »

Thanks!
I was running into issues making the bettime a local table, but know I know to just return it at the end.
I'll also change the other variables.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest