Howdy, Stranger!

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

Whitespaces in Sugarcube 2.0

I know this question has already been answered here, but I looked all the possible explanations and I don't understand any of them, so please, forgive me for opening this topic again.

My problem is that I want the player to choose from three options in an early passage, like this:

PrólogoInt5][$PInt5Txt to "1"
PrólogoInt5][$PInt5Txt to "2"
PrólogoInt5][$PInt5Txt to "3"

And then, in the next passage, there's going to be a different text for every option, and then a change in some variables, that will look like this:

<<if $PInt5Txt eq 1>>
<<set $sospecha to 10>>
<<set $comportamiento to 20>>
<<print "Text1">>
<<elseif $PInt5Txt eq 2>>
<<print "Text2">>
<<set $comportamiento to 25>>
<<set $sospecha to 0>>
<<else>>
<<print "Text3">>
<<set $comportamiento to 20>>
<<set $sospecha to 0>>
<</if>>

The thing is, that if I put the variables first, then I have a blank space on top of my text, but if I put them under the text, then the generic text that will follow is going to be much lower.

I don't know if I explained my question correctly, obviously I'm not a native english speaker, and I am also new in this forum, so if you have any doubt about my problem, if you find some mistake in my spelling or grammar or if I mess up the tags or something like that, feel free to point it out. Making mistakes is the first step towards knowledge.

Thank you for taking your time reading this huge block of text.

PD: I know that I can make different passages and I think that at least one of my problems will be gone, but I wouldn't like to have a lot of almost empty passages, because if I continue writing and end up making a huge game, I will regret not being a little bit more organized.

Comments

  • edited May 2016
    The issue: (effects all standard Story Formats, not just SugarCube)

    Generally each line-break you add to the contents of a Passage add an equivalent line-break (br element) to the generated output shown to the Reader. This behaviour can result in blank areas in the output especially for those Author that like to format the contents of their passages to make them more readable.

    The solution for SugarCube:

    You can use either the <<nobr>> macro or a backslash character \ to remove unwanter line-breaks from the generated output:
    <<nobr>>
    This text should appear
    on a single line!
    <</nobr>>
    
    This should also appear \
    on a single line!
    

    Your example includes text you want to output based on the value of the $PInt5Txt variable, but it is not clear if that text will contain line-breaks you may want to actually appear in the output.

    note: you don't need to use a <<print>> macro if you want to output text within an <<if>> macro, you can just hard-wire that text.

    If the text will not include required line-breaks then you could do the following:
    <<nobr>>
    <<if $PInt5Txt eq 1>>
    <<set $sospecha to 10>>
    <<set $comportamiento to 20>>
    Text1
    <<elseif $PInt5Txt eq 2>>
    Text2
    <<set $comportamiento to 25>>
    <<set $sospecha to 0>>
    <<else>>
    Text3
    <<set $comportamiento to 20>>
    <<set $sospecha to 0>>
    <</if>>
    <</nobr>>
    
    ... or if the text will contain required line-breaks you can do the following:
    note: there is no backslash character at the end of the lines we want the line-breaks to appear in the generated output.
    <<if $PInt5Txt eq 1>>\
    <<set $sospecha to 10>>\
    <<set $comportamiento to 20>>\
    This text should appear
    on two lines!\
    <<elseif $PInt5Txt eq 2>>\
    This text should appear
    on two lines!\
    <<set $comportamiento to 25>>\
    <<set $sospecha to 0>>\
    <<else>>\
    This text should appear
    on two lines!\
    <<set $comportamiento to 20>>\
    <<set $sospecha to 0>>\
    <</if>>\
    
  • Thank you for your answer, it was crystal clear. Also, thanks for the tips about the actual code. It really helps.
Sign In or Register to comment.