Save game states automatically

Here is a simple library I created to save the game state automatically. When you visit the game for the next time, it will load the latest state, so you don’t have to worry about save/load for different variables all the time. It also uses cookies as fallback, if local storage is not supported.

// Initialize the Storage object for player data
this.player = new Storage('Player', {
    level: 1,
});

// Increment the player's level
this.player.level++;

// Log the updated level
console.log(this.player.level);

Tutorial video

7 Likes

Wow simple and great!
:slightly_smiling_face: :+1:

I would like to see this in PlayCanvas asset store as well for quick access…

Hey, thanks for sharing this library! It’s awesome to see tools that make saving game states more seamless for developers. The use of local storage with cookies as a fallback is a smart touch—it really makes the experience smoother.

Just a heads-up for anyone using this on iPhones: Safari can sometimes have restrictions with local storage or handle cookies differently due to privacy settings. It might be something to watch out for when testing on iOS.

@avasinclair Please stop posting the link to the third party installer. We are deleting the posts because it’s not related to the topic nor web development