Footer not working

I’ve been looking at this guide: https://qjzhvmqlzvoo5lqnrvuhmg.on.drv.tw/UInv/Sample_Code.html#Main%20Menu and I follwoed the instructions to make a footer, but when I try the actual game, it says “cannot find a closing tag for macro <>” even though the code I’ve been using is as follows:

<<if tags().includes("bbar")>>

<<if>><div id="bottombar"><div id="bbblock"><div id="bbtext">Put your bottom bar text here.</div></div></div><</if>>

Just like it says in the guide. So why is it doing this? I followed the instructions for a header and it didn’t come up there.

EDIT: Actually, it seems to be not working for the header either, it just only shows the error message once.

You check the start of the second line of code. You have an open <<if>> without anything to check.

But there is an <</if>> at the end of it? I’m confused, I’m not very experienced with coding so sorry if I’m misunderstanding something.

You have 2 starts of <<if>> but only 1 closing <</if>>

<<if tags().includes("bbar")>>
  <<if>>
    <div id="bottombar">
       <div id="bbblock">
             <div id="bbtext">Put your bottom bar text here.</div>
       </div>
    </div>
  <</if>>
<- missing one closing <</if>>

or

<<if tags().includes("bbar")>>
  <<if>> <- this one is too many
    <div id="bottombar">
       <div id="bbblock">
             <div id="bbtext">Put your bottom bar text here.</div>
       </div>
    </div>
<</if>>

Unless you are trying to have two statements, one where there is nothing printed when the passage tag is “bbar” and something when the passage tag is not “bbar”

<<if tags().includes("bbar")>>
 <<else>>
    <div id="bottombar">
       <div id="bbblock">
             <div id="bbtext">Put your bottom bar text here.</div>
       </div>
    </div>
  <</if>>

I managed to get it working, but I have another question. Is there a way to get the text in the header or footer to change depending on the passage instead of having it stay the same throughout? I wanted to use my headers to display the chapter titles.

You can do that with an <<if>> statement, like this:

<<if passage() == "PassageName">>
    This text will only appear in PassageName.
<</if>>
1 Like

Like @svlin said, a conditional statement can work. Here’s what I have in mine:

	<<if tags().includes("first") or tags().includes("dark-empty")>>
		<<elseif tags().includes("credits")>><h1>Credits</h1>
		<<elseif tags().includes("character")>>
			<h1>Character</h1>
		<<elseif tags().includes("codex")>>
			<h1>Journal</h1>
		<<else>><h1>$chapter</h1>
	<</if>>

Depending on the tag of the passage, the Header is either empty (1st condition), shows Credits (2nd condition) - Characters (3rd) - Journal (4th), or display the chapter title in the variable $chapter (which I set in the link going to each new chapter).

@manonamora Okay as an example, but it seems a bit odd for actual use.

Issues:

  • <<if>> clauses with empty contents are a code smell—i.e., a sure sign you’re doing it wrong.
  • You don’t need multiple calls to both tags() and <Array>.includes(), as AND & OR variants of includes exist.

Addressing both:

<<if not tags().includesAny("first", "dark-empty")>>
	<<if tags().includes("credits")>><h1>Credits</h1>
	<<elseif tags().includes("character")>><h1>Character</h1>
	<<elseif tags().includes("codex")>><h1>Journal</h1>
	<<else>><h1>$chapter</h1>
	<</if>>
<</if>>

There’s still some HTML tag repetition in there, but let’s ignore that for this example.

1 Like

Thanks for the correction :slight_smile: