0 votes
by (510 points)

So I am trying to get <<nobr>> to work, but it just doesn't seem to want to get rid of line breaks created by <<if>> statements. Here's an example of what I put in the passage:

!!What's your body type?

Go ahead and go wild here. Humans are weird, especially in this town.

*[[Thin|Confirmation][$bod to 1]]
*[[Feminine|Confirmation][$bod to 2]]
*[[Average|Confirmation][$bod to 3]]
*[[Heavy-set|Confirmation][$bod to 4]]
<<nobr>><<if $vit >= 3>>*[[Athletic|Confirmation][$bod to 0]]//Note: If you can see this option, it means your Vitality stat was high enough to select it.//
<</if>><</nobr>>

now unless I am mistaken, it's supposed to get rid of all the line breaks inside that if statement, however when I actually test the game it still puts a line break before and after the the test inside the <<if>> statement. So it looks like this.

Before anyone suggest it, using the "\" method also does not work, it just seems to ignore it.

I am using Twine v2.1.3 and Sugarcube 2

1 Answer

0 votes
by (62.7k points)
selected by
 
Best answer

This is because of the list, not the nobr.  It's hard to make the parser play nice with <<if>>s sometimes.  You can do something like this:

!!What's your body type?

Go ahead and go wild here. Humans are weird, especially in this town.

*[[Thin|Confirmation][$bod to 1]]
*[[Feminine|Confirmation][$bod to 2]]
*[[Average|Confirmation][$bod to 3]]
*[[Heavy-set|Confirmation][$bod to 4]]
*<<if $vit >= 3>>[[Athletic|Confirmation][$bod to 0]]//Note: If you can see this option, it means your Vitality stat was high enough to select it.//<</if>>

...but the bullet will show up even if the <<if>> is false.  A better idea would probably be to just use plain old html instead:

!!What's your body type?

Go ahead and go wild here. Humans are weird, especially in this town.
<ul>
<li>[[Thin|Confirmation][$bod to 1]]</li>\
<li>[[Feminine|Confirmation][$bod to 2]]</li>\
<li>[[Average|Confirmation][$bod to 3]]</li>\
<li>[[Heavy-set|Confirmation][$bod to 4]]</li>\
<li><<if $vit >= 3>>*[[Athletic|Confirmation][$bod to 0]]//Note: If you can see this option, it means your Vitality stat was high enough to select it.//<</if>></li>\
</ul>

While not as nice-looking as SugarCube's markup, this should do what you want.

by (510 points)
having tried them both out, I think I like the first suggestion. It's a shame I can't hide the bullet, but in that case I don't mind if there was something else there instead if you didn't qualify, like a non-link message that just reads "You need higher vitality for this option" or something to that effect. Thanks for the help, I hadn't even considered that the bullets were what was causing the issue.
by (65.8k points)
Unfortunately, as a general rule, you cannot interleave markup, which is what you were attempting to do there.  That's simply a limitation of the current parser.

Putting one of the list item markup (leading asterisk) within the <<if>> separates it from the rest of the list, so at best you were looking at two lists there.  Beyond that, depending on how it's exposed within the <<if>>, the parser will decide that it's either a list item or plain text (i.e. just an asterisk).
by (100 points)
So, just to confirm...

(In case anyone is going to reply, using Twine 2 and newest Sugarcube)

There is no way in Sugarcube to 'hide' all the <<if>> in a large body as the parser cannot separate them then, as the OP has attempted both variants that have been recommended. (as have I and found no method that removes them from the displayed text) As <nobr> would conflict with the <<if>> statements that I have following.  

Sorry, I am very new to this, but have searched the interwebz extensively and found no solution that is amenable at this time. drat. I love the Sugarcube!

 

And Mad Exile, thanks so much for all the background, input, replies and content!
by (510 points)
It would seem so. I ended up just greying out options that you couldn't select, but it seems that if you want to use lists anyway, there is no way to hide the option. To clarify, the workaround that CHapel mentioned DOES work, but if you don't have an <<else>> text specified then you'll just have a floating bullet that doesn't seem to be attached to anything.

Obviously if you don't want to be all fancy like me and use a list then I'm almost positive that <<nobr>> and <<if>> statements will work perfectly fine together, it's the bulleted list that is messing everything up.
by (100 points)
Thank you kindly for the reply and the suggestions. I will rethink how I want to make this work to fit within the confines of Sugarcubes capabilities. One shoe does not always fit all, nor does my limited concepts of what can be done! Cheers!
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.
...