Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: faf1e6074a
Fetching contributors…

Cannot retrieve contributors at this time

68 lines (57 sloc) 1.858 kB


lime is a basic high score framework for saving and reloading global and local scores using the corona sdk (

Right now it's fairly rough around the edges and only supports some basic abilities for local scores. Local scores are persisted as json files.


json = require("json")
lime = require("lime")

-- setup
-- maxScores
--   the number of scores to keep per level
-- levelKeyFrom
--   the levelKeyFrom option takes a table of property names
--   that are used to generate and group scores, based off of
--   the optios table that you pass in at score creation
--   think of them as a method of creating dymanic score boards
--   if levelKeyFrom is empty then scores are added into lime as an array,
--   treating it as a single scoreboard
  maxScores = 10,
  levelKeyFrom = {"difficulty", "level"}

-- add a score
-- the only required key is "score", scores are kept sorted by "score"
-- if the keys specified in levelKeyFrom during setup are not passed,
-- scores are added into a global, nameless lobby
  score = player.score,
  level = 50,
  difficulty = "hard"

-- load all local scores for a level
-- localScores returns an array of tables containing whatever you included when adding the score
--   as well as a 'timestamp' field which was the time that the score was added
local scores = lime.localScores({
  level = 50,
  difficulty = "hard"

-- get amount of scores in this level

-- iterate over scores
for i, s in ipairs(scores) do
  local addedAt = lime.formatTimestamp(s.timestamp)
  print(s.score, addedAt)

-- clear all scores for a level,
  level = 50,
  difficulty = "hard"

-- write scores to a file
Jump to Line
Something went wrong with that request. Please try again.