LittleJS 1.28.0

Wavedash

WavedashPlugin

Wavedash plugin: starts the Wavedash SDK, sends achievements and posts and reads leaderboards

Constructor

new WavedashPlugin(leaderboards)wavedash.js:116

Start the Wavedash SDK when the game is on Wavedash, and make its leaderboards

leaderboards
// at the end of gameInit, with the leaderboards the game posts to
new WavedashPlugin({LEVEL_1: {lowerWins: true, display: 'milliseconds'}, HIGH_SCORE: {}});
wavedash.postScore('LEVEL_1', timeMs);

Members

Methods

Members

achievementRetry : number|undefinedwavedash.js:140
achievementsSent : Set<string>wavedash.js:136
achievementTries : Object<string, number>wavedash.js:138
leaderboards : Object<string, Promise<(string|undefined)>>wavedash.js:132

Each leaderboard's id by its name, once Wavedash has made or found it, undefined when it could not

leaderboardSettings : Object<string, {lowerWins?: boolean, display?: string}>wavedash.js:134
loadFailures : Map<string, ('failed'|'notSave')>wavedash.js:148
slotCalls : Map<string, Set<Promise<*>>>wavedash.js:146
slotQueues : Map<string, Promise<*>>wavedash.js:144
stats : Promise<boolean>|undefinedwavedash.js:142

Methods

cloudLoad(slot) → Promise<*>asyncwavedash.js:271

Load the value a cloud save slot holds: null when Wavedash says it holds none, undefined when it could not be loaded or off Wavedash, said in the console on Wavedash

  • Do not save over a slot that loaded as undefined, it may hold the player's save; loadFailure(slot) says why it did: 'notSave' for a file there that is not a save, where a game may offer to start over, 'failed' otherwise
  • A saved null loads as null, as an empty slot does
slot number

The slot number

Returns
  • The value saved, null for none, undefined for a load that failed
const save = await wavedash.cloudLoad(1);
cloudSave(slot, data) → Promise<boolean>asyncwavedash.js:237

Save a value to one of the player's cloud save slots, kept by Wavedash across devices; off Wavedash it does nothing

  • Any value JSON can hold, stored as the file saves/slot#.json
  • Wavedash takes at most 30 saves a minute and 300 an hour from a player, so save at checkpoints, the end of a level or when asked, not every frame; one over the limit is refused, said in the console
slot number

The slot number, any whole number the game picks

data *

The value to save

Returns
  • Whether it saved
wavedash.cloudSave(1, {level, coins});
getScores(name, offset, limit, friendsOnly) → Promise<(Array<Object>|undefined)>asyncwavedash.js:217

Read a leaderboard's entries, undefined off Wavedash or when it could not be read

name string

The leaderboard's name

offset number optional, default 0

How many entries to skip over

limit number optional, default 10

How many entries to read

friendsOnly boolean optional, default false

Only the player and their friends

Returns
  • The entries, as Wavedash gives them
getStat(name) → Promise<number>asyncwavedash.js:398

Read one of the player's stats, 0 for one never set or off Wavedash

name string

The stat's identifier

isActive() → booleanwavedash.js:159

Whether the game is on Wavedash, its SDK on the page

loadFailure(slot) → 'failed'|'notSave'|undefinedwavedash.js:287

Why a slot's last cloudLoad gave undefined: 'notSave' when the slot holds a file that is not a save, where a game may offer to start over, 'failed' when it could not be loaded, as off Wavedash or on a timeout, where a game must not save over it; undefined when it loaded a save or found the slot empty, or was not loaded

slot number

The slot number

postScore(name, score) → Promise<boolean>asyncwavedash.js:201

Post a score to a leaderboard, Wavedash keeping the player's best; off Wavedash it does nothing

  • A leaderboard not in the table given to the plugin is made the first time, higher wins and shown as a number
name string

The leaderboard's name

score number

A whole number, milliseconds for a time

Returns
  • Whether it was posted
setPresence(status, details) → Promise<boolean>asyncwavedash.js:423

Set what the player is doing, kept with their presence on Wavedash; off Wavedash it does nothing

status string optional

One line of what they are doing, like 'In a race'

details string optional

More about it, like 'Lap 2 of 3'; both left out clears it

Returns
  • Whether it was set
setStat(name, value, storeNow) → Promise<boolean>asyncwavedash.js:387

Set one of the player's stats, as made for the game in the Wavedash developer portal, which can unlock an achievement set to follow it; Wavedash keeps it about a second later, or at once with storeNow; off Wavedash it does nothing

name string

The stat's identifier

value number
storeNow boolean optional, default false

Keep it now, as at the end of a game, not a second later

Returns
  • Whether Wavedash took it