I suspect my use of Sugarcane shortcuts is biting me in the rear whenever I try to use Sugarcube, but I decided I probably need Sugarcube's save capability, unless there's a relatively simple way of saving some specified variables to browser storage. So I have two questions for anyone who knows Sugarcube well enough to answer.
1. Is the <<$variable/passage>> shortcut syntax that Sugarcane allows for replacing <<display passage>> or <<print $variable>> not supported in Sugarcube? I switched over and immediately practically everything broke because I've been using that syntax all over the place. (Do I really have to go back through and insert "display" or "print" into each individual link, in other words?)
2. Does Sugarcube saving allow for saving the content of specified variables too? For my project, it's not sufficient to simply save the passage that the player has reached because it's an RPG gamebook, so I need to save stats, experience, inventory, that sort of thing. It looks like there's a metadata property, but does that only hold one variable, or several? Can I stuff multiple arrays' worth of data into it? And can I intercept that information on load and distribute it back into the places it needs to be in order to restore the user's progress? I don't see much information on actually using the metadata property.
Thanks!
Comments
I'll let someone more knowledgeable answer your first question since I'm not familiar with SugarCane and have not much idea of what you're talking about there. I just use <<print $variable>> whenever I want to display a variable.
No, neither shorthand syntax is supported.
For the shorthand
<<print>>
syntax, you'd have to add the macro name (print
) back in.For pseudo macros (which is the purpose of the shorthand
<<display>>
syntax), you'd either need to add the macro name (display
) back in, if you weren't actually using it as a pseudo macro, or convert it over to a widget macro (via<<widget>>
), if you were using it as a pseudo macro.Yes. All history up to the point where the save is made, including the story's $variable store, is saved. Conversely, the entire saved history, including the story's $variable store, is restored when a save is loaded. The whole point of SugarCube's save system is to be as transparent as possible and just work. You don't have to do anything special, it just works, right out of the box.
You may want to check out the completely optional configuration properties for saves (
config.saves.*
). They offer several ways to change how the saves system behaves.You probably will not want, nor need, to use the SaveSystem API directly. As to the
metadata
property, specifically, it's just what it says on the tin (i.e. it's for metadata). You definitely do not want to be stuffing raw story data into it.