0 votes
by (750 points)
edited by
<<if $ArisaLove is 0>>\
<span class="blink"><font color="red">
<<set $ArisaLoveFeeling to 'ERASED'>></span></font>
<<elseif $ArisaLove isnot 0 and $ArisaLove lt 50>>\
<<set $ArisaLoveFeeling to '...'>>
<<elseif $ArisaLove gte 50 and $ArisaLove lt 100>>\
<<set $ArisaLoveFeeling to '1'>>
<<elseif $ArisaLove gte 100 and $ArisaLove lt 150>>\
<<set $ArisaLoveFeeling to '2'>>
<<elseif $ArisaLove gte 150 and $ArisaLove lt 200>>\
<<set $ArisaLoveFeeling to '3'>>
<<elseif $ArisaLove gte 200 and $ArisaLove lt 250>>\
<<set $ArisaLoveFeeling to '4'>>
<<elseif $ArisaLove gte 250 and $ArisaLove lt 300>>\
<<set $ArisaLoveFeeling to '5'>>
<<elseif $ArisaLove gte 300 and $ArisaLove lt 400>>\
<<set $ArisaLoveFeeling to  '6'>>
<<elseif $ArisaLove gte 400 and $ArisaLove lt 500>>\
<<set $ArisaLoveFeeling to '7'>>
<<elseif $ArisaLove gte 500>>
<<set $ArisaLoveFeeling to '8'>>
<<else>>\
<<set $ArisaLoveFeeling to '???'>>
<</if>>\
<<if $ArisaHate is 0>>\
<font color="white"><<set $ArisaHateFeeling to '1'>></font>
<<elseif $ArisaHate gt 0 and $ArisaHate lt 50>>\
<font color="yellow"><<set $ArisaHateFeeling to '2'>></font>
<<elseif $ArisaHate gt 50 and $ArisaHate lt 100>>\
<font color="orange"><<set $ArisaHateFeeling to '3'>></font>
<<elseif $ArisaHate gt 100 and $ArisaHate lt 150>>\
<font color="blue"><<set $ArisaHateFeeling to '4'>></font>
<<elseif $ArisaHate gt 150 and $ArisaHate lt 200>>\
<font color="green"><<set $ArisaHateFeeling to '5'>></font>
<<elseif $ArisaHate gt 200 and $ArisaHate lt 300>>\
<font color="purple"><<set $ArisaHateFeeling to '6'>></font>
<<elseif $ArisaHate gt 300 and $ArisaHate lt 400>>\
<font color="#7a2791"><<set $ArisaHateFeeling to '7'>></font>
<<elseif $ArisaHate gt 400 and $ArisaHate lt 500>>\
<font color="red"><<set $ArisaHateFeeling to '8'>></font>
<<if $ArisaHate gte 500>>
<span class="blink"><font color="red"><<set $ArisaHateFeeling to '9'>></font></span>
<<else>>\
<<set $ArisaHateFeeling to "???">>
<</if>>\
<<if $ArisaDepression is 0>>\
<<set $ArisaDepressionFeeling to '1'>>
<<elseif $ArisaDepression isnot 0 and $ArisaDepression lt 50>>\
<<set $ArisaDepressionFeeling to '2'>>
<<elseif $ArisaDepression gte 50 and $ArisaDepression lt 100>>\
<<set $ArisaDepressionFeeling to '3'>>
<<elseif $ArisaDepression gte 100 and $ArisaDepression lt 200>>\
<<set $ArisaDepressionFeeling to '4'>>
<<elseif $ArisaDepression gte 200 and $ArisaDepression lt 300>>\
<<set $ArisaDepressionFeeling to '5'>>
<<elseif $ArisaDepression gte 300>>\
<<set $ArisaDepressionFeeling to '6'>>
<<else>>\
<<set $ArisaDepressionFeeling to '???'>>
<</if>>\

 

I'm using this in the StoryCaption and it gives me theses 2 errors:

Error: cannot find a closing tag for macro <<if>>
<<elseif>> was found outside of a call to its parent macro <<if>>

At first, I thought it was due to \, but almost every single elseif I used is giving me the same error.

 

What am I doing wrong? I'm about to pull my hair out!

1 Answer

+1 vote
by (37.1k points)
selected by
 
Best answer

OK, first things first, there's no point in setting a font around a <<set>> macro.  There's no output from that macro, so there is no text to change the font of.

Second, even if a <<set>> macro did have some output, this won't work:

<span class="blink"><font color="red">
<<set $ArisaLoveFeeling to 'ERASED'>></span></font>

This is because you can't do "<span><font>...</span></font>", you would have to do "<span><font>...</font></span>" instead. HTML elements can't cross over each other like that.  If one HTML element starts within another, then it has to close within that same element.

Third, if you're doing code like this:

<<if $ArisaLove is 0>>
...
<<elseif $ArisaLove isnot 0 and $ArisaLove lt 50>>
...
<<elseif $ArisaLove gte 50 and $ArisaLove lt 100>>
...

then you're witing redundant checks.  You don't need to do "$ArisaLove isnot 0" when $ArisaLove can't possibly be 0, because if it was it would have triggered the previous "<<if $ArisaLove is 0>>" check.  A much shorter version which provides the same results goes like this:

<<if $ArisaLove is 0>>
...
<<elseif $ArisaLove lt 50>>
...
<<elseif $ArisaLove lt 100>>
...

And finally, your bug which is causing both of those errors you're seeing appears to be here:

...
<<elseif $ArisaHate gt 400 and $ArisaHate lt 500>>\
<font color="red"><<set $ArisaHateFeeling to '8'>></font>
<<if $ArisaHate gte 500>>
<span class="blink"><font color="red"><<set $ArisaHateFeeling to '9'>></font></span>
<<else>>\
<<set $ArisaHateFeeling to "???">>
<</if>>\

The "<<if $ArisaHate gte 500>>" should actually be "<<elseif $ArisaHate gte 500>>".  (Though, again, the <span> and <font> elements do nothing here, because there's no text shown inside of them.)

Hope that helps!  :-)

by (750 points)
edited by
I'll try this out, the set does display messages but I changed them to 1,2,3 ect for simplicity reasons.

 

also, wouldn't the elseif lt 100 also trigger the lt 50 if the value of the variable is 40?

 

Also, thank you for your time, it helps a lot! This helped and I feel kinda dumb. I rewrote the code over 4 times and a simple if was the problem?! Well, I can laugh about it now.
by (149k points)

> wouldn't the elseif lt 100 also trigger the lt 50 if the value of the variable is 40?

When you create a <<if>>/<<elseif>>/<<else>> structure, only the code associated with the first condition that is evaluated as 'true' is executed.

<<if $ArisaLove is 0>>
...
<<elseif $ArisaLove lt 50>>
...
<<elseif $ArisaLove lt 100>>
...
<<elseif $ArisaLove lt 150>>
...
<</if>>

So if you had a structure like the above and $ArisaLove was 40 then only the code associated with the <<elseif $ArisaLove lt 50>> macro would be executed.

by (37.1k points)

"This helped and I feel kinda dumb. I rewrote the code over 4 times and a simple if was the problem?! Well, I can laugh about it now."

Don't feel dumb.  This happens to even the most experienced programmer.  Sometimes you just need a fresh set of eyes to look at the problem.

Besides, you haven't seen anything until you've spent hours hunting down a problem which ultimately turned out to be a space in the wrong place or a missing/extra ">" somewhere.

The easiest way to find stuff like that is to comment out large chunks of code (i.e. "/* commented out code */") until the problem goes away.  Then progressively whittle down the chunk of code which you have commented out, until it's a small enough section of code that you can read through it one character at a time to find the problem.

Have fun!  ;-)

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.
...