LittleJS 1.28.0

Medals

LittleJS Medal System

  • Achievement/trophy system for games
  • Medal class with name, description, icon, and unlock tracking
  • Automatic saving to local storage, unless a service like Newgrounds holds the medal (see Medal.isLocal)
  • Visual display queue with slide-in notifications
  • The Newgrounds plugin extends it with NewgroundsMedal, held on the server while logged in, and the Wavedash plugin with WavedashMedal, saved here and sent to Wavedash
  • Setting debugMedals = true in the game code before medalsInit skips the load and the save, sends nothing to Wavedash, and in the debug build logs the Newgrounds traffic; it is not exported, so only a script tag build can set it

Classes

Functions

Constants

Typedefs

Functions

medalsForEach(callback)medalSystem.js:134

Calls a function for each medal

callback MedalCallbackFunction
medalsInit(saveName)medalSystem.js:61

Initialize medals with a save name used for storage

  • Call this after creating all medals
  • Loads which medals are unlocked from the save, and writes the catalog back
  • A medal a service like Newgrounds holds is left as it is, see Medal.isLocal
  • A medal unlocked before the first call stays unlocked and is saved by it
saveName string

The localStorage key the medals are kept under, a different one from the game's own readSaveData and writeSaveData, or each would overwrite the other

medalsReset()medalSystem.js:140

Reset all medals to locked and persist the cleared catalog

  • A medal a service like Newgrounds holds is left alone, the service has it

Constants

medals : Object<number, Medal>medalSystem.js:46

List of all medals

Typedefs

MedalCallbackFunction(medal)medalSystem.js:125
medal Medal