Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Avoiding extra spacing with choices

So on some passages I will have certain lines (if conditions are met) removed as the user returns to the passage, and this will leave gaps.  I don't know how using <NOBR> will help.  For example:
[img[n-04-2014-2888]]
Where would you like to go?

<<if $pink neq 1>>[[Go towards the left]]<<endif>>
<<if $playedchess neq 1>>[[Talk to the man at the chess table]]<<endif>>
<<if $wapp neq 1>>[[Approach the women with the dog]]<<endif>><<if $sshouse neq 1>><<if $dog is 1>>[[Try the women with the dog again|ss2]]<<endif>><<endif>>
<<if $wapp is 1>>[[Go over the footbridge to the other side of the park|bridge]]<<endif>>
[[Leave the park|001]]
I'm probably not doing this the best way but it's how I've been making it work, it just doesn't look pretty when big gaps appear between the lines, so is there a better way?

Comments

  • This is a classic question and one I asked myself. :) There are two elements to the answer: the backslash character ("\") and the HTML element <br>.

    In your case, what I would do is add a backslash to the end of each line on which you have an <<if>> statement, and put a <br> right before each <<endif>>. Example:
    <<if $pink neq 1>>[[Go towards the left]]<br><<endif>>\
    The "\" removes the linebreak for each line it punctuates. The <br> inside the <<if>> statement conditionally adds a linebreak.

    This way, you get to preserve the readability of your code while providing the output solution, which is to run all the <<if>> statements together on a single line for output and then adding a linebreak back in for each <<if>> statement that actually resolves and displays link text.

    For more complexly-written passages, you'll end up using <<nobr>> too. Which you can add inline the usual way, <<nobr>><<endnobr>>, or you can give an entire passage a "nobr" tag and there will be no linebreaks in that passage (meaning you have to add them manually where you want them, with <br>).
  • There also the &lt;&lt;silently&gt;&gt; &lt;&lt;endsilently&gt;&gt; option.  The only problem with this is that it won't put any input out if any is specified between the tags.  For instance
    <<silently>>
    <<print "Hello World!">>
    <<endsilently>>
    won't produce any output whatsoever, but it's good when used for code that doesn't display anything directly.  It does fall down when you try to split the code with the tags though.  Using &lt;&lt;silently&gt;&gt; for the bits you don't want line breaks in and then slapping &lt;&lt;endsilently&gt;&gt; for the bit's you want to display won't work.

    Due to this, &lt;&lt;silently&gt;&gt; wouldn't be suitable for what you're attempting to do, but might come in useful later on if you have something that is, erm, silent.
  • loopernow wrote:

    This is a classic question and one I asked myself. :) There are two elements to the answer: the backslash character ("\") and the HTML element <br>.

    In your case, what I would do is add a backslash to the end of each line on which you have an <<if>> statement, and put a <br> right before each <<endif>>.


    Thanks that does the trick!
Sign In or Register to comment.