First question: I want my "displayHeader" variable to be set to "false" until I set it to "true" at the beginning of the story. I put "(set: $displayHeader to true)" in my startup passage, in my welcome passage I put "(set: $displayHeader to false)" then in my "begin" passage I put "(set: $displayHeader to true)" but for some reason my header doesn't show up in my welcome (as it is not supposed to) but then
still doesn't show up in begin or any passage after that.
Am I doing it wrong?
Second question: I'm working with approval ratings. I want my relationships page to show a simple line that says "Your relationship with [x person] is:" and depending on the approval rating (from 0 = hatred to 100 = love) what it says. So, if Theodore's relationship is 75, I want it to say, "Your relationship with Theodore is: Intimate."
My startup sets approval and relationship to 50 for each character (for now).
My relationships code:
Theodore Approval Rating: $theodoreApproval
Louisa Approval Rating: $louisaApproval
Emma Approval Rating: $emmaApproval
Your relationship with Theodore is: (if: $theodoreRelationship is 50)[friendly](if: $theodoreRelationship <= 40)[tense](if: $theodoreRelationship <= 25)[cold](if: $theodoreRelationship <= 10)[based in mutual hatred](if: $theodoreRelationship <= 60)[friendly](if: $theodoreRelationship <= 75)[flirtatious](if: $theodoreRelationship <= 85)[intimate](if: $theodoreRelationship <= 100)[love]
(link-goto: "Return", (history:)'s last)
Unfortunately, when my Theodore relationship is set to 40, this shows as so:
Inventory | Craft Something | Relationships | Skills
Theodore Approval Rating: 35
Louisa Approval Rating: 50
Emma Approval Rating: 50
Your relationship with Theodore is: tensefriendlyflirtatiousintimatelove
Return
How sexy.
I presume I'm using my greater/less thans wrong (I had it set to less than but it didn't like that at all). What should I do to make this work?
Comments
There are 2 problems with your approval rating code.
The first is that all the conditions will be checked, regardless of whether they're true or not. You need to use elseif for the later checks.
The second problem is due to the ordering, if you change to it to elseif, if the value is 10 then it'll print the result for the <= 40 check rather than the <= 10 check.
The following should do what you want:
I added extra line breaks for legibility.
I attach a copy of my twine which refuses to header on/off.
So when it's displaying the "Begin" passage, $displayHeader only gets set to true after it's run the line and decided not to show the header. When I tried it, the header did appear when I got to the "to the door." passage. The easiest fix would be to move the line setting $display header to true to the "Height" passage, then you'll get the header when "Begin" shows.
BTW since $displayHeader is a true/false value you don't need the is true part of the test. You can just write
Also, in the "you stop to offer him greeting." passage you're trying to increment $theodoreApproval with the line which doesn't work. You need to do
To fix this issue in your example move the (set: $displayHeader to true) to the end of your welcome passage.
If you want to leave the extra line breaks in so your code stays more readable then you can use Harlowe's built-in line break removal feature to remove them before the result is shown to the reader/player.
To do this simply wrap the text/code you want line-breaks removed from in a set of curly brace { } characters.
A modified version of prof_yaffle's example, note the { character before the (if:) macro and the } character after the last hook:
I added extra line breaks for legibility.[/quote]