It looks like you're new here. If you want to get involved, click one of these buttons!
<<set $addload= function() {$chkpnts.add(state.history[0].passage.title); /*$chkpnts is an array of passage names*/ new Wikifier(StoryMenuObject, "[[Checkpoint "+($loads+1)+"|"+$chkpnts[$loads]+"]]"); $loads++; } >>but what should I write instead of "StoryMenuObject"?
$chkpntsvars[$loads]=state.history[0].variablesand later, executed by a click in StoryMenu,
state.history[0].variables=$chkpntsvars[$selected]work?
Comments
And I believe this is why your update to the storyMenu element is disappearing, because it is being overwritten with the current contents of the StoryMenu passage.
I am curious why you are assigning Javascript functions to $variables instead of creating custom macros.
So, the more important problem remains: how to save and restore the variables? I've checked already - direct assignment like in my initial post doesn't work.
I prefer function calls to macros. More convenient both to write and to use, e.g. I can insert them in a link, like
re: Running your own Callback function:
The buildSnapback function currently uses the back macro (defined here and extended here) to return the story to the selected menu item, you could either extend or replace the existing back macro with your own. The existing back macro can be extended in a script tagged passage like so:
I think my code should go before 'back_original', not after?
However, I found another way: as I have prerender() already, I added my code there for the passages marked with "bookmark" tag.