0 votes
asked ago by (370 points)

Okay. My passages tend to come out looking like this:

|Hook_1>[This is an active hook that shows up when the player first arrives in the passage.

(link: "Hallo.")[
	(show: ?Hook_2)
	(replace: ?Hook_1)[]]
]\
|Hook_2)[This is the first of many hidden hooks that will be revealed/erased using the above (link:) macro, or one built similarly to it.

(link: "Wie geht's?")[
	(show: ?Hook_3)
	(replace: ?Hook_2)[]]
]\
|Hook_3)[This is another hidden hook. This is the last hook of the passage.

(link: "Tschüss!")[
	(goto: "An Invisible Passage")]
]

Since this is all a single passage, my sidebar (which contains tools like 'Roll a Die', 'Flip a Coin', and 'Draw 5 Cards') doesn't update when the player moves from hook to hook.

Is there a way to add something to the sidebar and/or each hook's (link: "to the next hook")[ set of macros] that will allow me to make the sidebar "refresh" whenever the link is clicked? I'd really rather not have to break 7 passages out into the 35 challenges that make them up just to fix this problem, as the entire point behind setting passages up like this was to make my work screen less cluttered.

Please and thank you?

1 Answer

0 votes
answered ago by (109k points)
selected ago by
 
Best answer

You haven't explained how you are updating your side-bar area, which makes it difficult to give you an answer that matches your exact needs.

One common method used to dynamically update a section of the existing page is to...

1. Place the content to be updated within a child passage. (eg. Sidebar Links)

(link: 'Roll a Die')[...]
(link: 'Flip a Coin')[...]
(link: 'Draw 5 Cards')[...]


2. Display the contents of that child passage within a named hook (eg. links) and place that named hook where you want that content to appear in the current page. (eg. within your side-bar area)

|links>[(display: 'Sidebar Links')]


3. Refresh the contents of the named hook (eg. links) as needed. (eg. when a link is used to reveal one of your hidden hooks.)

(replace: ?links)[(display: 'Sidebar Links')]

 

commented ago by (370 points)
Considering that, in the example given, the sidebar content is basically the example given with the appropriate coding in the brackets, this worked perfectly! Thank you!
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.
...