0 votes
by (2.2k points)
I have a header in my story that I want to always be evaluating the health variable, my code isn't perfect for it yet, I'm still new to all this, but it works. I'm more concerned about how to get it to force the player to a death passage when the health variable hits zero. Is that even possible?

Also, is there a way to disable a header showing for certain passages?

1 Answer

0 votes
by (159k points)
selected by
Best answer

is there a way to disable a header showing for certain passages

The contents of header (and footer) tagged passages are always evaluated, so the best you can do is hide the visual output. How you do that basically depends on if you care if the contents of the header passage is executed of not:

A. If the header passage contains code you don't want executed (like the updating of variables) then you should wrap the existing content within an (if: $variable) macro and use the value of the $variable to control if the associated hook's content is processed or not.

1. Initialise the controlling variable within your story's startup tagged special passage.

(set: $showHeader to true)

2. Wrap then existing contents of your header tagged special passage in an (if:) macro.

(if: $showHeader)[
	... Current contents of your Header tagged passage ...

3. Change the value of the controlling variable to false before you want to display a passage without the header.

(set: $showHeader to false)

4. Change the value back to true when you want the header to be shown again.


B. If you don't care if the code in the header passage is executed or not then you can use a passage tag and some CSS to hide the visual output of the header.

1. Assign a known passage tag to the passages you don't want the header to appear on, this example uses a tag of no-header

2. Place CSS like the following in your story's Story Stylesheet area, it hides all header passages on all passages marked with the no-header tag.

tw-passage[tags~="no-header"] tw-include[type="header"] {
	display: none;

3. If you have multiple header tagged special passages and you only want to hide the visual output of one of them then change the above CSS to reference the name/title of that header passage instead.
eg. If your header passage is named/titled My Header then the CSS selector would look like the following:

tw-passage[tags~="no-header"] tw-include[title="My Header"] {
	display: none;


force the player to a death passage

Look at the (go-to:) macro, you could do something like the following

(if: $health is 0)[(go-to: "Death")]