Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Import/export save data to a file #553

Open
MrRafael-dev opened this issue Sep 3, 2022 · 5 comments
Open

Suggestion: Import/export save data to a file #553

MrRafael-dev opened this issue Sep 3, 2022 · 5 comments

Comments

@MrRafael-dev
Copy link
Contributor

MrRafael-dev commented Sep 3, 2022

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 run command 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).
@aduros
Copy link
Owner

aduros commented Sep 3, 2022

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.

@MrRafael-dev
Copy link
Contributor Author

MrRafael-dev commented Sep 3, 2022

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.

@zetanumbers
Copy link
Contributor

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.

@JerwuQu
Copy link
Contributor

JerwuQu commented Apr 17, 2024

Is there more we want to do for this issue, like state import/export, or is it done?

@zetanumbers
Copy link
Contributor

There are mutable globals we would ideally need to export/import.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants