How to check if user ever visited given passages/tags after using Jump To?

0 votes
asked Dec 7, 2017 by NotKostas (410 points)

Imagine following scenario: when player character dies, background music stops, special "game over" sound is played and player is given choice to restart the game or open Jump To dialog. When the player jumps back to selected bookmark, background music resumes.

I tried to implement this using PassageHeader where <<if>> checks if user visited certain passages, but apparently Jump To completely erases not only current history, but expired too, because both State.hasPlayed(passageTitle) and visited([passages…]) return false when I check for that passage where death happened. I also tried visitedTagsprevious and even using variables, just in case. 

The only solution I see now is to write flag into localStorage, but this will open a whole new can of worms. Am I missing something? Is there better, may be "think outside of the box" solution?

1 Answer

+1 vote
answered Dec 7, 2017 by TheMadExile (31,720 points)
selected Dec 9, 2017 by NotKostas
Best answer

The Jump To menu erases nothing.  All it does is send the player back in time to the destination moment—i.e. it rolls the player back to an earlier point in the history.  The reason neither visited() nor State.hasPlayed() found the death passage at that point is because it was in the potential future history, which neither of them check.

If your goal is simply to restart your BGM, you could simply set a value on setup in the death passage—I can't really think of a reason it needs to be stateful.  For example:

<<set setup.pcDied to true>>

Then simply check for that in PassageReady or whatever—n.b. I wouldn't use PassageHeader for bookkeeping tasks like this as it generates output.

commented Dec 8, 2017 by NotKostas (410 points)

Well, "erases" was obviously poorly chosen word, I'm sorry. I know that it rolls the player back.

simply set a value on setup in the death passage

Thanks, looks promising. Where can I read more about this setup thing? Can't find it in the docs.

I wouldn't use PassageHeader for bookkeeping tasks

Thanks for the advice, I'll definitely move music management there.

commented Dec 8, 2017 by greyelf (56,990 points)

 Where can I read more about this setup thing?

Information about the setup object can be found within the Special Names documentation.

commented Dec 8, 2017 by TheMadExile (31,720 points)

It is as greyelf says.  There's not much to the setup object's documentation, however, because there's not much to it.  It's simply a generic object, which is within SugarCube's scope but not part of the history, whose sole purpose is for authors to use as they like.

commented Dec 8, 2017 by NotKostas (410 points)
Thanks for quick help!
Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.