0 votes
by (8.7k points)

This really looks like it ought to work, but...  frown

::Passage
<<set $nationality to "USA">>
His office is on the top floor, so you'll need to take the <<lift>>.
::Widget
<<widget "lift">>\
  <<if $nationality == "USA">>\
    <<= "elevator">>\
    <<elseif $nationality == "UK">>\
    <<= "lift">>\
  <</if>>\
<</widget>>

That outputs a space between the <<widget>> and the full stop/period at the end of the sentence, so it looks like this:

His office is on the top floor, so you'll need to take the elevator .

Can anybody see what I'm doing wrong?

 

 

1 Answer

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

Two things:

  1. The indention is causing the space, since you're using trailing line continuations.  Using leading line continuations instead will fix the issue, while still allowing you to use indention.
  2. Using the print macro to output static text is utterly pointless.

Try something like the following:

<<widget "lift">>
	\<<if $nationality is "USA">>
		\elevator
	\<<elseif $nationality is "UK">>
		\lift
	\<</if>>
\<</widget>>

 

by (8.7k points)

Thank you, Exile.  smileyyes

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