Howdy, Stranger!

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

Blank spaces when options are removed

edited November 2016 in Help! with 2.0
Is there any way round preventing the blank spaces when various options are removed from a passage?

For instance.
You are in a hut. A pile of dry logs sit alongside a hearth. There's bread on the table.

Exit hut
Light fire
Eat bread
Now lets say the player chooses to light the fire. On refresh they will see:
You are in a hut. A pile of dry logs sit alongside a hearth. There's bread on the table.

Exit hut

Eat bread
Anyway to prevent that gap?

Comments

  • note: you need to read the SugarCube 2 manual more, especially the Markup and Macro sections, as many of your recent questions are answered in them.

    As stated in the Line Continuations of the Markup related documentation you can use a backslash character to remove the line-breaks at the end of lines. You can then manually add line-breaks back in using a HTML <br> element as needed.

    The follow example is based on the one in this comment
    options:
    [[Exit shack|Outside Shack]]\
    <<if $hasWood and not $isFireLit>><br>[[Start a fire|Start Fire]]<</if>>\
    <<if $hasWood>><br>[[Craft a weapon|Craft Weapon]]<</if>>\
    <<if $hasWeapon>><br>[[Hunt for food|Hunting]]<</if>>\
    <<if $hasRawMeat and $isFireLit>><br>[[Cook meal|Cook Food]]<</if>>\
    
  • edited November 2016
    Using your example, greyelf. I set the options in my Shack passage to the following, and I still get the blank spaces when the options are removed because they no longer apply.
    Outside
    <<if $hasWood and not $isFireLit>><<click "Light fire">><<set $isFireLit to true>><<goto "Shack">><</click>><</if>>\
    <<if $hasWood and not $hasWeapon and $noCraft>><br>Craft weapon<</if>>\
    <<if $hasRawMeat and $isFireLit>><br>Cook food<</if>>\
    <<if $isFireLit>><<audio "fire_crackling" play>><</if>>
    I'm now using Sugarcube 2.11.0
  • You are missing a backslash at the end of the Exit shack link and a <br> element before the <<click "Light fire">> macro call, this is causing the extra blank line once the fire has been lite.

    note: Your example does not explain what the $noCraft variable is for, if it is being used to determine if the weapon has been crated yet then you can also do that by checking the $hasWeapon variable. (which should be set to true in the Craft weapon passage)
    If the $hasWeapon variable is false then it has not been crafted yet, if it is true then the weapon has been crafted and the related link will be hidden in the Shack passage.
  • edited November 2016
    Ah, I see. My apologies. Yeah, that works.

    The $noCraft variable was a rather ugly workaround for a problem I couldn't fix.

    As the player tos and fros between the Shack and the Outside, I couldn't get 'Craft Weapon' not to show up if the player had already crafted it, because it also shows up if he has collected wood.

    This means that if the first time he collects wood and chooses to Craft a Weapon instead of Light a fire, then goes back out for more wood to light the fire, the Craft Weapon option will be there again because of the IF conditions.

    So I had to create this $noCraft variable which I set to false in the Craft Weapon passage.

    I fully follow and agree with your logic, but for whatever reason the Craft Weapon would show up under certain circumstances, even though it had already been crafted previously.
  • Check where you are assigning a value to the $hasWeapon variable, you should be setting it to false in the StoryInit special passage and to true in the Craft weapon passage. If you don't assign it a value in any other passage then the link related code in the Shack passage should work correctly.
  • I'll have a look again tomorrow. In principle I know you're right, but at the time with my fuzzled head I couldn't get it behaving how I wanted.
Sign In or Register to comment.