Howdy, Stranger!

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

Lists, whitespace and seperate lines. (Harlowe)

edited July 2016 in Help! with 2.0
Hey guys,

I’m working on an inventory system and while I can get a bunch of stuff to work going backwards and forwards I've run into a problem that is driving me mad. The inventory displays itself on a separate page, when an item or weapon is set to true it simply displays that item in the “inventory” (another page). However! The list of items in the inventory takes up a huge bunch of space. Using {} on either end of this long list does fix this problem but I want each item on the list to take up a separate line rather than all being clumped together. In other words, instead of looking like this:

Wood Axe - Mace - Short Sword - Chain Mail - Buckler - Torch - Bedroll

I’m trying to make the list of items look like this:

Wood Axe -
Mace -
Short Sword
Chain Mail -
Buckler -
Torch -
Bedroll -

This problem is further complicated by the fact that I’m only setting certain items to be true at certain times, this means that without using {} huge gaps of white space appear from the items that have not been set to true but are still present on the page. I've tried using {} in different ways inside the code with varying results but nothing that works for the entire list. Does anyone have an idea?
1st Page 
(set: $Bedroll to true)
(set: $Torch to true)
(set: $Buckler to true)
(set: $LightHelm to true)
(set: $ChainMail to true)
(set: $Mace to true)
(set: $WoodAxe to true)
(set: $ShortSword to true)

2nd Page
{(if: $Club is true)[Club - ]
(if: $Dagger is true)[Dagger - ]
(if: $WoodAxe is true)[Wood Axe - ]
(if: $Javelin is true)[Javelin - ]
(if: $Hammer is true)[Hammer - ]
(if: $Mace is true)[Mace - ]
(if: $Staff is true)[Staff - ]
(if: $Spear is true)[Spear - ]
(if: $ShortSword is true)[Short Sword - ]
(if: $Wrench is true)[Wrench - ]
(if: $LightCrossbow is true)[Light Crossbow - ]
(if: $Shortbow is true)[Shortbow - ]
(if: $CompositeBow is true)[Composite Bow - ]
(if: $Sling is true)[Sling - ]
(if: $HeavyCrossbow is true)[Heavy Crossbow - ]
(if: $Longbow is true)[Longbow - ]
(if: $Blowgun is true)[Blowgun - ]
(if: $HandCrossbow is true)[Hand Crossbow - ]
(if: $BattleAxe is true)[Battle Axe - ]
(if: $Glaive is true)[Glaive - ]
(if: $GreatAxe is true)[Great Axe - ]
(if: $TwoHandedSword is true)[Two Handed Sword - ]
(if: $Halberd is true)[Halberd - ]
(if: $Longsword is true)[Longsword - ]
(if: $Maul is true)[Maul - ]
(if: $Pike is true)[Pike - ]
(if: $Rapier is true)[Rapier - ]
(if: $Scimitar is true)[Scimitar - ]
(if: $Trident is true)[Trident - ]
(if: $Warhammer is true)[Warhammer - ]
(if: $LightArmour is true)[Light Armour - ]
(if: $PaddedArmour is true)[Padded Armour - ]
(if: $LeatherArmour is true)[Leather Armour - ]
(if: $HideArmour is true)[Hide Armour - ]
(if: $ChainMail is true)[Chain Mail - ]
(if: $ScaleMail is true)[Scale Mail - ]
(if: $Breastplate is true)[Breatplate - ]
(if: $RingMail is true)[Ring Mail - ]
(if: $SplintMail is true)[Splint Mail - ]
(if: $HalfPlate is true)[Half-Plate - ]
(if: $FullPlate is true)[Full-Plate - ]
(if: $Buckler is true)[Buckler - ]
(if: $SmallShield is true)[Small Shield - ]
(if: $MediumShield is true)[Medium Shield - ]
(if: $LargeShield is true)[Large Shield - ]
(if: $TowerShield is true)[Tower Shield - ]
(if: $Torch is true)[Torch - ]
(if: $Bedroll is true)[Bedroll]}

Comments

  • The trick is to use a back-slash on the end of each line to suppress the line-break and to add the line-break inside the (if:) macro's associated hook.

    note: My example will only do the first seven items, just use the same technique for all of the rest.

    1. Initialise your variables in your story's startup tagged passage:
    (set: $Club to false)
    (set: $Dagger to true)
    (set: $WoodAxe to true)
    (set: $Javelin to false)
    (set: $Hammer to false)
    (set: $Mace to true)
    (set: $Staff to true)
    
    2. Use CSS like the following to suppress the startup adding empty space to the first passage of your story, it goes in your Story Stylesheet area:
    tw-story tw-include[type="startup"] {
    	display: none;
    }
    
    3. Format your (if:) macros and their associated hooks like the following, notice that you don't need the "is true" part if your variable contains a Boolean value.
    (if: $Club)[
    Club - ]\
    (if: $Dagger)[
    Dagger - ]\
    (if: $WoodAxe)[
    Wood Axe - ]\
    (if: $Javelin)[
    Javelin - ]\
    (if: $Hammer)[
    Hammer - ]\
    (if: $Mace)[
    Mace - ]\
    (if: $Staff)[
    Staff - ]
    
  • Yup that solves it! Thanks greyelf!
Sign In or Register to comment.