Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Basic "return from menu passages" handling for Harlowe

A common problem people have once they have added a menu system to their story is how to exit that menu system in a way that the Reader is returned directly to the last non-menu passage shown to them.

The following describes how to do this using a passage tag (menu) to mark the passages that make up your menu system, a variable ($lastPassage) to store the name of the last non-menu passage shown to the Reader, and a header tagged passage which tracks the menu tag to update the $lastPassage variable.

1. Setting up the $lastPassage variable.
This should be done in your story's startup tagged passage, which is a good place to initialise all your story's variables. If you don't have a startup tagged passage yet then create a new passage, name it whatever you like (I name mine Startup) and assign the new passage a startup tag.
(set: $lastPassage to "")

2. Tracking menu passages.
Add a menu tag to each of passages that make up your menu system.

3. Tracking last non-menu passage:
First create a new passage and name it whatever you like (I named mine "Last Passage Tracking"), next assign the new passage a header tag, and finally add the following to the new passage.
(if: not ((passage:)'s tags contains "menu"))[(set: $lastPassage to (passage:)'s name)]
The above works by

3a. Using the (passage:) macro to access the array of tags assign to the current passage being shown to the Reader

3b. It uses the contains operator to determine if the menu tag is in the array, true if it is found and false

3c. It uses the not operator to invert the true/false result of 3b because we want to know when the menu is not in the array.

3d. If the tag is not in the array we assign the name of the current passage to the $lastPassage variable.

4. Linking back to the last non-menu passage.
You can use a combination of the (link-goto: ) macro and the $lastPassage variable to show a link that the Reader can use to do this, this link should be made available within all the passsages that you have assigned the menu tag to.
(link-goto: "Leave Menu", $lastPassage)

WARNING:
Currently there is no macro that allows the Author go backwards to a previous passage in a way that undoes history, this means that if the Reader clicks on the Undo button directly after they have exited your menu system then they will return to the last passage of the menu system they were viewing. Harlowe does not have the equivalent of SugarCube's <<back>> macro.

Comments

Sign In or Register to comment.