Why doesn’t my AI game save between visits?
Put it on Cassette and the save sticks. Add Cassette’s script, start the game inside Cassette.ready, and the localStorage your game already writes becomes the player’s save: kept with their account, backed up daily, and there on their next visit and on any device they sign in on.
Tell your agent
Make my game keep its saves on cassette.gg.- Start inside Cassette.ready
- Storage read before the save has loaded is empty, and a write then lands on top of the real save.
- Keep saves in localStorage
- localStorage, cookies and cassette.files follow the player. sessionStorage is this page only. IndexedDB is saved too, but a database the game already has open is not re-read when a player signs in or out mid-game.
- Room for it
- 10 MiB per player per game.
- Checked at upload
- A build that uses the browser’s storage without Cassette’s script is refused, with the reason, before players ever see it.
The whole fix:
<script src="https://cassette.gg/sdk/v2-shim.js"></script> <!-- the first script in <head> -->
<script>
Cassette.ready.then(() => { // the player's saves have loaded
startGame() // localStorage is now the player's save
Cassette.started() // the game is on screen
})
</script>The script and storage, for agents (§1)