Thread: Scorpion Engine
View Single Post
Old 29 January 2022, 09:46   #1770
earok
Registered User
 
Join Date: Dec 2013
Location: Auckland
Posts: 3,542
I think I'll skip streaming (maybe I'll do one in my morning, another 10-12 hours or so) but I did do one major new feature to experimental: Save and Load support. It's not extensively tested but does seem to work.

It's a little complex as you might imagine, so I've updated the dialogue sample in Experimental to save and load data from disk. Basically, how it works is:
  • You can save all of the variables in a single codeblock to a file (so you may want to have a codeblock called "SaveGame" that has no code, just variables for example).
  • There's a new Data category of command (only with Save and Load, though there's other Data features planned)
  • You have an infinite number of save slots (so you can save your "SaveGame" code block multiple times if you allowed your user to have multiple save files)
  • You can check a Saved or Loaded variable to see if the save was actually successful.

So you can do this, for example:

Code:
Save codeblock "savegame" to slot 0 (saves to file "savedata/savegame.000")
If Saved
;Save was successful
else
;Save was not successful. Disk full etc?
endif
Code:
Load codeblock "savegame" from slot 0 (loads from file "savdedata/savegame.000")
If Loaded
;Load was successful
else
;Load was not successful. Never saved to that slot before?
endif
Further notes:
  • It may not work right if you change your SaveGame codeblock later (such as adding, removing or reordering variables), and then try to load an old save file. You'll need to take care of save file version management yourself (probably just making sure that you always delete old saves would be enough).
  • Obviously this won't work as-is on CD32, though I'm familiar with how NVRAM works so CD32 will be supported in a future update.
earok is offline  
 
Page generated in 0.04519 seconds with 11 queries