Hey all. Basically what I'm trying to do is load up a title screen in my game, click "Begin" to begin the game, then go to a passage which loads the game's autosave, and if there is no autosave, goes to the first passage of the game. I have found the Save API, but don't really know how to do anything with it (I didn't even know how to create my own macro before this, to illustrate my complete lack of knowledge with JavaScript, though my programmer background has helped me pick up on the basics). I can't seem to load anything or do anything. I assume the game automatically saves to the auto-save slot whenever the player does something - if I'm wrong about this, clarification would be appreciated. If anybody could show me how best to simply do the above, I would really appreciate it. Thanks so much!
Comments
The configuration options are generally placed within your story's Story Javascript area.
If you look at the examples for the autoload / autosave related options you will see that you can configure SugarCube to prompt the Reader if there is an autosave to load.
Commonly there are passage within your story where you do not want autosave to occur like at the very start of your story, as explained in the documentation you can use the Config.saves.isAllowed option to control when autosave is allowed
You could use code like the following which will not do an autosave for any passage that has been assigned a nosave passage tag.
The other advantage to this is if you want to have any other commands activate on clicking that link (like setting variables) you can insert them before the <<script>> macro. For example, in my story I use that to stop the title screen music upon clicking load autosave. If you let the game do it automatically anything running on the title screen will just keep going until it gets stopped, as the simple act of loading an autosave does not halt anything currently in progress.
Eg.
I recommend against always making the player load an autosave, as for whatever reason they might want to restart from the beginning again. However, you could do it easily with variables like so:
1. on the screens where you have a tagged autosave activating, write
<<set $autosave to true>>
2. On your start game screen write:
Where "First Passage" is the very next passage after the start screen.
I prefer to control these things with variables and click events for maximum customization.
In my game I prefer to limit where a player gets autosaved to avoid any confusing bugs arising so use
in the script passage to autosave only on passages I tag autosave. I then put these at key save points (the start of every turn), so a player is always loaded in at the same relative spot, rather than all over the place.