LittleJS Newgrounds Plugin
- NewgroundsMedal extends Medal with Newgrounds API functionality
- When logged in, Newgrounds holds the player's NewgroundsMedals: they unlock once the server confirms and the local save leaves them alone
- A plain Medal is never touched, so a game can use the plugin for scoreboards alone
- Without a session the medal and scoreboard lists still come in, so the medals get their names and icons; unlocking on the server and posting scores need a logged in player
- Create the medals as NewgroundsMedals with their ids on Newgrounds, then new NewgroundsPlugin(app_id, cipher); medalsInit is still needed, before or after
- Encrypts medal unlocks and posted scores, the calls Newgrounds secures, with the browser's own WebCrypto when the app has a cipher, no library needed
- Logs a view when it starts, and provides functions to unlock medals and to post and read scoreboards
- Tells the Newgrounds page around the game when a medal unlocks or a score posts, as the official client does
- Checks the session every minute when logged in, which keeps it alive, and plays as not logged in once it is lost
- Where the browser has AbortSignal.timeout, a request that takes longer than 15 seconds fails like one that could not reach the server
- Every call is a fetch, so the functions return promises; await newgrounds.ready for the medals and scoreboards
- Source
Classes
Members
(static) newgrounds :NewgroundsPlugin
Global Newgrounds object
Type:
- NewgroundsPlugin
- Source