PassageHeader in SugarCube

Twine Version: 2.3.16
Story Format: 2.36.1

I know that a header can be applied to all passages via the PassageHeader code, but can a header be applied to individual passages, simply to keep that passage’s buttons on screen if a lot of content makes scrolling necessary?

A header for all passages would not work for me, as each button to a location also has a time factor for distance travelled attached to it, so it would be always be correct if used as PassageHeader.


The alternate would be a rather complicated code that knows what passage the player is on, and could calculate the time from that. I think that solution is more like science fiction, or even fantasy. :slight_smile:

You can’t conditionally apply a header or footer tagged Passage to the ‘current’ Passage being shown, you can however use the <<if>> family of macros to conditional display the contents of that header or footer tagged Passage…

eg. The following ‘header’ Passage will only display its content when a the ‘current’ Passage being shown has been assigned a forest Passage Tag.

<<if tags().includes("forest")>>Only show this message for 'forest' tagged passages.<</if>>

eg. The following ‘header’ Passage will not display its content if the ‘current’ Passage being shown has been assigned a noheader Passage Tag.

<<if ! tags().includes("noheader")>>Only show this message if the 'current' Passage has not been assigned a 'noheader' tag<</if>>

note: You don’t need to base the conditional expressions on the assignment of Passage Tags, any condition expression will do.

2 Likes

@Greyelf’s approach works but might be unnecessary. Instead of dealing with PassageHeader you can use the include macro and plug it into passages manually.

So create a passage titled: reusable and enter the content or buttons that you need.

Then, when you want it to show up in a passage, type

<<include "resuable">>

You don’t necessary have to use it at the top of the passage, but since you are imitating the header that is what you would do.

You can repeat this as often as you like, replacing reusable with any other title.

1 Like

Thank you both @Greyelf and @pbparjeter. I used the method pbparjeter suggested as it had less coding for me, but I appreciate both of your efforts.

It works perfectly.

I used this for the gymnasium in my game

<<check_hour '9' '17' 'The gym is open' 'The gym is closed'>>

and put

<<include "gymtime">>

into the passage for the gymnasium entry level passage, which does indeed show that it was open or closed.

However, can the code be amended to include a variable, ie

<<set $gymopen to false>>

Or do I need to include the <<set $gymopen to false>> into the StoryInit, and have the code say somehting like:

<<if $gymopen is false>>
The gym is closed
<<else>>
"whatever dialogue I previously had in the passage"
<</if>>

So that I can adapt the dialogue to the situation better?

Though you could set a variable within the <<check_hour>> widget, it doesn’t check unless you are in the passage.

You would need to create a system that indexes what is open and when, and checks it every turn to accomplish what I think you are describing.

Frankly that is a lot of work when you can just assume the player is only in the gym when it is open, though I don’t your full plan of course.

1 Like

I know I’m trying to make an overly complicated game, at least from the creation point of view, but I really need to try it so I can see what is possible and what isn’t. I also know what I would like to see in a game, and try to include as much of that as I can.

Sometimes, what they call achievements ignorance is the best way to proceed.

And sometimes it really, really isn’t :slight_smile:

One way around this, without creating a whole new system is this.

Create the door to the gym

<<check_hour '9' '17' 'The gym is open, you can enter the [[Gym]]' 'The gym is closed'>>

Create a passage titled Gym and enter this

<<check_hour '9' '17' '<<include "In the open gym">>' '<<include "In the closed gym">>'>>

Then create two more passages, In the open gym and In the closed gym and enter what you’d like the player to see in each case.

1 Like

Yes, I was just trying to figure that one out. Thanks again!

1 Like