So I have saving deactivated in some parts of my game, like menus and combat. I initially was going to hide the save option, but that'll also prevent loading, so it's not quite the elegant solution I was hoping for (though it is plan b).
Instead, when the option to save is clicked within the save dialog, and the game does not in fact save, I'd like an alert to pop up and tell the player.
I'd appreciate some guidance on how exactly to do so without nuking the whole menu option.
Comments
Whoops. Sorry about that. I'm using Config.saves.isAllowed, as in:
I know I should probably be using an || there instead of an else if. In fact I'll probably just change that now.
As to alerting the player. You may use the UI.alert() dialog method, though that will take a bit of magic to make work from within the Config.saves.isAllowed callback.
For example, try something like the following:
EDIT: The $(document).one('tw:dialogclosed', function () { … }) bit sets up an event handler which executes the UI.alert() dialog method when the Saves dialog closes. That is necessary because attempting to switch to the alert dialog from within the Config.saves.isAllowed callback without doing so will cause it to be closed whenever Config.saves.isAllowed returns. As I said, a bit of magic.
Thanks Exile.
In the SugarCube 2 Documentation, under Config Object, a note says:
All well and good, makes sense.
I have
And
II haven't run into any problems yet, but I was wondering if one or either of these was a potential problem. I don't want to be playing with fire.
You're printing a variable, which presumably can and will change, with the <<print>> macro. That is the very definition of dynamic code.
I would suggest placing any version information in the StorySubtitle special passage and keeping StoryTitle static. For example: NOTE: You don't really need the <<print>> macro to display a simple story/temporary variable due to the naked variable markup.
If you simply must have it formatted as you do now. I'd again suggest keeping StoryTitle static, however, this time you'd hide its element. You'd then place the above code in either the StoryBanner or StorySubtitle special passage and style the associated element to look like the StoryTitle element normally does. For example:
I recommend against putting that in the StoryMenu special passage. Its sole purpose is populate the story menu with links—it will not display anything other than links right now and I've toyed with the idea of making it skip processing of non-link markup altogether.
The StoryCaption special passage is the usual go-to for code like that, though you'd want to ensure that no output was generated. That said, the PassageDone special passage would work just as well and is already silent.
My mistake, that was in fact for illustrative purposes.
Haha. I'm bad at this. In my defense I read the warning after I'd already written the code, and since it hadn't lead to any problems, I thought maybe you meant something else.
I see. I have a display in that the StoryMenu too: It runs the passage:
It works fine, but it seems like it might be best to change that soon, so thanks for the heads up.
Also, unless you have something else in audioMute, the nobr tag wasn't doing anything useful—the <<link>> macro's contents are silent. It wasn't really hurting anything either, but my point is that less is more—i.e. don't do unnecessary stuff.