Suggestion: Import/export save data to a file
Currently, save data is limited to where you play the game:
- Playing on a different site won't share the same save, and it's not possible to move from one location to another, at least not without hacking through developer tools via console.
- If you clear your cookies and history regularly, chances are that your saves are going to be erased, and any progress you've made will have to be done again.
- There's no way to share your progress with others, which can be a fun aspect for completionists, or games with custom maps/characters.
- If you switch between PC and mobile, there's no way of keeping your scores or in-game progress between both of them.
- Games ran through
w4 runcommand will share the same save data, which will inevitably cause corruption between different saves.
My suggestion is to have an option to import/export save data to a file, allowing players to share and use them however they like. Not only this solves a large amount of limitations, it can also provide a lot more if used creatively:
- Save editors for both players and developers.
- If done correctly, save data can be used as an expansion pack, which can provide extra content for games.
- For games with level editors or character creators, players could create and share their levels and characters.
- Moving your progress between sequels or other games (ex: carrying your old inventory, or unlocking a secret character after beating another game as a form of easter egg).
We have state saving/loading mapped to the 2 and 4 keys. Maybe Shift-2 can open a dialog to save the state to a file, and Shift-4 to browse to open?
The state contains both RAM and disk, so it wouldn't be exactly what you're requesting, but might be the simplest and most intuitive for users to understand. Saving the disk alone could be interesting for sharing data between different tools though.
Having the same option for save states would also be a good addition, but I don't think that should replace the ability of doing the same with disk.
Apart from file sizes, I have a few reasons for this:
- Loading a state on a game with different versions would either revert the game to another version or crash.
- Save editors would be considerably harder to make: instead of only changing a couple of values, now you'll have to deal with the entire RAM.
- Sharing saves between sequels or tools would be impossible.
That said, I think we should still be able to save/load the disk alone, even if an option for save states already existed.
Maybe disk import/export could have their own options on the menu?
Continue
Save state
Load state
Save disk
Load disk
Clear disk
Copy netplay URL
Reset cart
We could also have an option to clear disk data, in case we load the wrong save or just want a fresh start.
In regards to saving: I was thinking of just having a single, uncompressed binary file with 1KB of data. Not sure if the file extension could be just .bin or should have it's own extension, though.
I've come up with a bit of a hack to export the gamestate. First you need to save gamestate of a cartridge <Enter> -> Save State. This is a way to get memory as ArrayBuffer object of this saved gamestate:
document.querySelector('wasm4-app').savedGameState.memory
So i grabbed function _arrayBufferToBase64 from stackoverflow, and the whole command becomes:
_arrayBufferToBase64(document.querySelector('wasm4-app').savedGameState.memory )
Output of witch you can copy and decode bytes within your terminal to pass it whereever you need.
Is there more we want to do for this issue, like state import/export, or is it done?
There are mutable globals we would ideally need to export/import.