Closed sizhongbin closed 2 months ago
Unless I'm mistaken, this is already part of v2.37.0
.
Unless I'm mistaken, this is already part of
v2.37.0
.
Thanks for quick reply. I've checked the 2.37.0 document. Looks like the serialize ion API is replaced by base64. But I cannot find any difference except the Promise return. I'm still only able to encode the current save slot or load it immediately. I cannot encode/decode ALL the slots. Did I miss something?
Yes. Check out the documentation on Save.browser.export()
and Save.browser.import()
.
Yes. Check out the documentation on
Save.browser.export()
andSave.browser.import()
.
Oh i figured out. Yes the import/export can backup/restore all the slots to/from a save file. But unfortunately, what i need is a JSON string so that i can SELECT/INSERT/UPDATE it in postgresSQL easily.
I guess I should create my own save/load function instead of using the brower save API, so that I can set/get the JSON string I want to/from localStorage and do something before loading.
I suppose I could add .exportToBase64()
and .importFromBase64()
methods or something similar.
Made some changes:
Save.browser.export()
and Save.browser.import()
to Save.disk.export()
and Save.disk.import()
.Save.base64.export()
and Save.base64.import()
.The latter two are what you should need.
Great! Thanks a lot. I'll try it soon.
Is your feature request related to a problem? I'm working on a game with cloud save feature based on Supabase database. The process in my plan should be like: :: Start User login with useid and password. If successd, goto :: LoadGame
:: LoadGame
The problem is that serialize/deserialize feature only works on the current slot. And a load will be immediately processed after deserialize.
Describe the solution you'd like. Save.serializeAll(): Return a JSON string like: {"slot0":"Slot 0 Serialized String","slot1":"Slot 1 Serialized String","slot2":"Slot 2 Serialized String"} Save.deserializeAll(string): Deserializes the given save string created via Save.serializeAll() and cover the current localStorage.
Describe alternatives you've considered. Maybe some other solutions using the current Serialization API?
Additional context. Nope.