Okay, this seems to work well but unfortunately this interferes with the autosave script I have in my game.
The autosave is in my Startup passage and looks like this:
{
<!-- Set autosave variables -->
(set: $_version to "1.0")
(set: $_autosave_slot to "autosave")
(set: $_autosave_filename to "save v"+$_version)
(set: $_start_passage to "Start")
}
The other part of the autosave is in the first passage, like so:
(unless: (saved-games:) contains $_autosave_slot and (datavalues: (saved-games:)) contains $_autosave_filename)[(goto: $_start_passage)]
<center><div class="menu">''[[New Game->$_start_passage]]
(link: "Continue Game")[(load-game: $_autosave_slot)]''
Here is the toggle-hints script, adapted from greyelf's suggestions:
(if: $allowHints is true)[(print: "Hints On:")](else:)[(print: "Hints Off:")]
(click-replace: "Hints On")[Click Toggle to change whether hints are displayed in future passages]
(link-repeat: "Toggle")[(if: $allowHints is true)[(set: $allowHints to false)] ](else:)[(set: $allowHints to true)]
However, it seems that something to do with the toggling interferes with the autosave, resulting in this error:
The game's variables contain a complex data structure; the game can no longer be saved.
The error happens after I click on "toggle", but does not happen when I don't.