Friday, August 18, 2017

Converting Lone Wolf to Twine and SugarCube - Part 6 - Equipment Gone Wild



     Okay, another day after another night of writing, revising and cursing code. I'm trying to add the code to handle Backpack items, dropping them and picking up only part of a group. It isn't working (as usual, I've put several hours into it and while I'm getting there, I'm not there yet). Thing is, once I get it working I have to copy and modify it for the other 3 types of backpack items - so more copy-paste-change variables-copy-paste like I did for the weapons. Now, just above I posted how the code for 1 Weapon has increased - with some placeholders for the unfinished stuff, here is roughly how big ALL the equipment code is going to be when I get it working...

<<switch $founditem[0]>>

<<case "Gold">>
You pick up $founditem[1] Gold Crowns,
<<set $Gold = $Gold + $founditem[1]>>
<<if $Gold > 50>>
<<set $Gold = 50>>
but your Belt Pouch only holds 50 Gold Crowns,
<</if>>
you now have $Gold Gold Crowns.

<<case "Helmet">>
<<if $Helmet > 0>>You are already wearing a helmet!
<<else>>
<<set $Helmet = 1>>You put on the Helmet.
<</if>>

<<case "Armor">>
<<if $Armor > 0>>You are already wearing armor!
<<else>>
<<set $Armor = 1>>You put on the Chainmail Waistcoat.
<</if>>

<<case "Dagger">>
<<nobr>>
<<if $CountHands == 0>>
<<set $Daggers = 1>>You pick up the Dagger.<<set $CountHands++>>

<<elseif $CountHands == 1>>
<<if $Daggers == 0>>
<<set $Daggers = 1>>You pick up the Dagger.<<set $CountHands++>>

<<elseif $Daggers == 1>>You already have a Dagger, do you want to pick up a spare?
<<linkreplace " Yes">><<set $Daggers = 2>>You now have 2 Daggers.<<set $CountHands++>><</linkreplace>>
<<linkreplace " No">>You leave the item.<</linkreplace>>
<</if>>

<<elseif $CountHands >= 2>>
<<if $Daggers == 2>>You already have two Daggers, your hands are full!

<<elseif $Daggers == 1>>
You already have a Dagger! Do you want to drop your other weapon and have 2 Daggers instead?
<<linkreplace " Yes">>
<<set $Daggers = 2>>
<<if $Spears == 1>><<set $Spears = 0>><<elseif $Maces == 1>><<set $Maces = 0>><<elseif $ShortSwords == 1>><<set $ShortSwords = 0>><<elseif $Warhammers == 1>><<set $Warhammers = 0>><<elseif $Swords == 1>><<set $Swords = 0>><<elseif $Axes == 1>><<set $Axes = 0>><<elseif $Quarterstaffs == 1>><<set $Quarterstaffs = 0>><<elseif $Broadswords == 1>><<set $Broadswords = 0>>
<</if>>
You now have 2 Daggers.<</linkreplace>><<linkreplace " No">>You leave the item.<</linkreplace>>

<<elseif $Daggers == 0>>
What item do you want to drop to make room for the Dagger?
<<if $Spears >= 1>>
<<linkreplace " the Spear">><<set $Spears-->><<set $Daggers = 1>>You drop your Spear and gain a Dagger.<</linkreplace>><</if>>
<<if $Maces >= 1>>
<<linkreplace " the Mace">><<set $Maces-->><<set $Daggers = 1>>You drop your Mace and gain a Dagger.<</linkreplace>><</if>>
<<if $ShortSwords >= 1>>
<<linkreplace " the Short Sword">><<set $ShortSwords-->><<set $Daggers = 1>>You drop your Short Sword and gain a Dagger.<</linkreplace>><</if>>
<<if $Warhammers >= 1>>
<<linkreplace " the Warhammer">><<set $Warhammers-->><<set $Daggers = 1>>You drop your Warhammer and gain a Dagger.<</linkreplace>><</if>>
<<if $Swords >= 1>>
<<linkreplace " the Sword">><<set $Swords-->><<set $Daggers = 1>>You drop your Sword and gain a Dagger.<</linkreplace>><</if>>
<<if $Axes >= 1>>
<<linkreplace " the Axe">><<set $Axes-->><<set $Daggers = 1>>You drop your Axe and gain a Dagger.<</linkreplace>><</if>>
<<if $Quarterstaffs >= 1>>
<<linkreplace " the Quarterstaff">><<set $Quarterstaffs-->><<set $Daggers = 1>>You drop your Quarterstaff and gain a Dagger.<</linkreplace>><</if>>
<<if $Broadswords >= 1>>
<<linkreplace " the Broadsword">><<set $Broadswords-->><<set $Daggers = 1>>You drop your Broadsword and gain a Dagger.<</linkreplace>><</if>>

<<linkreplace " None">>You leave your items unchanged.<</linkreplace>><</if>><</if>><</nobr>>

<<case "Spear">>
<<nobr>>
<<if $CountHands == 0>>
<<set $Spears = 1>>You pick up the Spear.<<set $CountHands++>>

<<elseif $CountHands == 1>>
<<if $Spears == 0>>
<<set $Spears = 1>>You pick up the Spear.<<set $CountHands++>>

<<elseif $Spears == 1>>You already have a Spear, do you want to pick up a spare?
<<linkreplace " Yes">><<set $Spears = 2>>You now have 2 Spears.<<set $CountHands++>><</linkreplace>>
<<linkreplace " No">>You leave the item.<</linkreplace>>
<</if>>

<<elseif $CountHands >= 2>>
<<if $Spears == 2>>You already have two Spears, your hands are full!

<<elseif $Spears == 1>>
You already have a Spear! Do you want to drop your other weapon and have 2 Spears instead?
<<linkreplace " Yes">><<set $Spears = 2>><<if $Daggers == 1>><<set $Daggers = 0>><<elseif $Maces == 1>><<set $Maces = 0>><<elseif $ShortSwords == 1>><<set $ShortSwords = 0>><<elseif $Warhammers == 1>><<set $Warhammers = 0>><<elseif $Swords == 1>><<set $Swords = 0>><<elseif $Axes == 1>><<set $Axes = 0>><<elseif $Quarterstaffs == 1>><<set $Quarterstaffs = 0>><<elseif $Broadswords == 1>><<set $Broadswords = 0>>
<</if>>
You now have 2 Spears.<</linkreplace>><<linkreplace " No">>You leave the item.<</linkreplace>>

<<elseif $Spears == 0>>
What item do you want to drop to make room for the Spear?
<<if $Daggers >= 1>>
<<linkreplace " the Dagger">><<set $Daggers-->><<set $Spears = 1>>You drop your Dagger and gain a Spear.<</linkreplace>><</if>>
<<if $Maces >= 1>>
<<linkreplace " the Mace">><<set $Maces-->><<set $Spears = 1>>You drop your Mace and gain a Spear.<</linkreplace>><</if>>
<<if $ShortSwords >= 1>>
<<linkreplace " the Short Sword">><<set $ShortSwords-->><<set $Spears = 1>>You drop your Short Sword and gain a Spear.<</linkreplace>><</if>>
<<if $Warhammers >= 1>>
<<linkreplace " the Warhammer">><<set $Warhammers-->><<set $Spears = 1>>You drop your Warhammer and gain a Spear.<</linkreplace>><</if>>
<<if $Swords >= 1>>
<<linkreplace " the Sword">><<set $Swords-->><<set $Spears = 1>>You drop your Sword and gain a Spear.<</linkreplace>><</if>>
<<if $Axes >= 1>>
<<linkreplace " the Axe">><<set $Axes-->><<set $Spears = 1>>You drop your Axe and gain a Spear.<</linkreplace>><</if>>
<<if $Quarterstaffs >= 1>>
<<linkreplace " the Quarterstaff">><<set $Quarterstaffs-->><<set $Spears = 1>>You drop your Quarterstaff and gain a Spear.<</linkreplace>><</if>>
<<if $Broadswords >= 1>>
<<linkreplace " the Broadsword">><<set $Broadswords-->><<set $Spears = 1>>You drop your Broadsword and gain a Spear.<</linkreplace>><</if>>

<<linkreplace " None">>You leave your items unchanged.<</linkreplace>><</if>><</if>><</nobr>>

<<case "Mace">>
<<nobr>>
<<if $CountHands == 0>>
<<set $Maces = 1>>You pick up the Mace.<<set $CountHands++>>

<<elseif $CountHands == 1>>
<<if $Maces == 0>>
<<set $Maces = 1>>You pick up the Mace.<<set $CountHands++>>

<<elseif $Maces == 1>>You already have a Mace, do you want to pick up a spare?
<<linkreplace " Yes">><<set $Maces = 2>>You now have 2 Maces.<<set $CountHands++>><</linkreplace>>
<<linkreplace " No">>You leave the item.<</linkreplace>>
<</if>>

<<elseif $CountHands >= 2>>
<<if $Maces == 2>>You already have two Maces, your hands are full!

<<elseif $Maces == 1>>
You already have a Mace! Do you want to drop your other weapon and have 2 Maces instead?
<<linkreplace " Yes">><<set $Maces = 2>><<if $Daggers == 1>><<set $Daggers = 0>><<elseif $Spears == 1>><<set $Spears = 0>><<elseif $ShortSwords == 1>><<set $ShortSwords = 0>><<elseif $Warhammers == 1>><<set $Warhammers = 0>><<elseif $Swords == 1>><<set $Swords = 0>><<elseif $Axes == 1>><<set $Axes = 0>><<elseif $Quarterstaffs == 1>><<set $Quarterstaffs = 0>><<elseif $Broadswords == 1>><<set $Broadswords = 0>>
<</if>>
You now have 2 Maces.<</linkreplace>><<linkreplace " No">>You leave the item.<</linkreplace>>

<<elseif $Maces == 0>>
What item do you want to drop to make room for the Mace?
<<if $Daggers >= 1>>
<<linkreplace " the Dagger">><<set $Daggers-->><<set $Maces = 1>>You drop your Dagger and gain a Mace.<</linkreplace>><</if>>
<<if $Spears >= 1>>
<<linkreplace " the Spear">><<set $Spears-->><<set $Maces = 1>>You drop your Spear and gain a Mace.<</linkreplace>><</if>>
<<if $ShortSwords >= 1>>
<<linkreplace " the Short Sword">><<set $ShortSwords-->><<set $Maces = 1>>You drop your Short Sword and gain a Mace.<</linkreplace>><</if>>
<<if $Warhammers >= 1>>
<<linkreplace " the Warhammer">><<set $Warhammers-->><<set $Maces = 1>>You drop your Warhammer and gain a Mace.<</linkreplace>><</if>>
<<if $Swords >= 1>>
<<linkreplace " the Sword">><<set $Swords-->><<set $Maces = 1>>You drop your Sword and gain a Mace.<</linkreplace>><</if>>
<<if $Axes >= 1>>
<<linkreplace " the Axe">><<set $Axes-->><<set $Maces = 1>>You drop your Axe and gain a Mace.<</linkreplace>><</if>>
<<if $Quarterstaffs >= 1>>
<<linkreplace " the Quarterstaff">><<set $Quarterstaffs-->><<set $Maces = 1>>You drop your Quarterstaff and gain a Mace.<</linkreplace>><</if>>
<<if $Broadswords >= 1>>
<<linkreplace " the Broadsword">><<set $Broadswords-->><<set $Maces = 1>>You drop your Broadsword and gain a Mace.<</linkreplace>><</if>>

<<linkreplace " None">>You leave your items unchanged.<</linkreplace>><</if>><</if>><</nobr>>

<<case "Short Sword">>
<<nobr>>
<<if $CountHands == 0>>
<<set $ShortSwords = 1>>You pick up the Short Sword.<<set $CountHands++>>

<<elseif $CountHands == 1>>
<<if $ShortSwords == 0>>
<<set $ShortSwords = 1>>You pick up the Short Sword.<<set $CountHands++>>

<<elseif $ShortSwords == 1>>You already have a Short Sword, do you want to pick up a spare?
<<linkreplace " Yes">><<set $ShortSwords = 2>>You now have 2 Short Swords.<<set $CountHands++>><</linkreplace>>
<<linkreplace " No">>You leave the item.<</linkreplace>>
<</if>>

<<elseif $CountHands >= 2>>
<<if $ShortSwords == 2>>You already have two Short Swords, your hands are full!

<<elseif $ShortSwords == 1>>
You already have a Short Sword! Do you want to drop your other weapon and have 2 Short Swords instead?
<<linkreplace " Yes">><<set $ShortSwords = 2>><<if $Daggers == 1>><<set $Daggers = 0>><<elseif $Spears == 1>><<set $Spears = 0>><<elseif $Maces == 1>><<set $Maces = 0>><<elseif $Warhammers == 1>><<set $Warhammers = 0>><<elseif $Swords == 1>><<set $Swords = 0>><<elseif $Axes == 1>><<set $Axes = 0>><<elseif $Quarterstaffs == 1>><<set $Quarterstaffs = 0>><<elseif $Broadswords == 1>><<set $Broadswords = 0>>
<</if>>
You now have 2 Short Swords.<</linkreplace>>
<<linkreplace " No">>You leave the item.<</linkreplace>>

<<elseif $ShortSwords == 0>>
What item do you want to drop to make room for the Short Sword?
<<if $Daggers >= 1>>
<<linkreplace " the Dagger">><<set $Daggers-->><<set $ShortSwords = 1>>You drop your Dagger and gain a Short Sword.<</linkreplace>><</if>>
<<if $Spears >= 1>>
<<linkreplace " the Spear">><<set $Spears-->><<set $ShortSwords = 1>>You drop your Spear and gain a Short Sword.<</linkreplace>><</if>>
<<if $Maces >= 1>>
<<linkreplace " the Mace">><<set $Maces-->><<set $ShortSwords = 1>>You drop your Mace and gain a Short Sword.<</linkreplace>><</if>>
<<if $Warhammers >= 1>>
<<linkreplace " the Warhammer">><<set $Warhammers-->><<set $ShortSwords = 1>>You drop your Warhammer and gain a Short Sword.<</linkreplace>><</if>>
<<if $Swords >= 1>>
<<linkreplace " the Sword">><<set $Swords-->><<set $ShortSwords = 1>>You drop your Sword and gain a Short Sword.<</linkreplace>><</if>>
<<if $Axes >= 1>>
<<linkreplace " the Axe">><<set $Axes-->><<set $ShortSwords = 1>>You drop your Axe and gain a Short Sword.<</linkreplace>><</if>>
<<if $Quarterstaffs >= 1>>
<<linkreplace " the Quarterstaff">><<set $Quarterstaffs-->><<set $ShortSwords = 1>>You drop your Quarterstaff and gain a Short Sword.<</linkreplace>><</if>>
<<if $Broadswords >= 1>>
<<linkreplace " the Broadsword">><<set $Broadswords-->><<set $ShortSwords = 1>>You drop your Broadsword and gain a Short Sword.<</linkreplace>><</if>>

<<linkreplace " None">>You leave your items unchanged.<</linkreplace>><</if>><</if>><</nobr>>

<<case "Warhammer">>
<<nobr>>
<<if $CountHands == 0>>
<<set $Warhammers = 1>>You pick up the Warhammer.<<set $CountHands++>>

<<elseif $CountHands == 1>>
<<if $Warhammers == 0>>
<<set $Warhammers = 1>>You pick up the Warhammer.<<set $CountHands++>>

<<elseif $Warhammers == 1>>You already have a Warhammer, do you want to pick up a spare?
<<linkreplace " Yes">><<set $Warhammers = 2>>You now have 2 Warhammers.<<set $CountHands++>><</linkreplace>>
<<linkreplace " No">>You leave the item.<</linkreplace>>
<</if>>

<<elseif $CountHands >= 2>>
<<if $Warhammers == 2>>You already have two Warhammers, your hands are full!

<<elseif $Warhammers == 1>>
You already have a Warhammer! Do you want to drop your other weapon and have 2 Warhammers instead?
<<linkreplace " Yes">><<set $Warhammers = 2>><<if $Daggers == 1>><<set $Daggers = 0>><<elseif $Spears == 1>><<set $Spears = 0>><<elseif $Maces == 1>><<set $Maces = 0>><<elseif $ShortSwords == 1>><<set $ShortSwords = 0>><<elseif $Swords == 1>><<set $Swords = 0>><<elseif $Axes == 1>><<set $Axes = 0>><<elseif $Quarterstaffs == 1>><<set $Quarterstaffs = 0>><<elseif $Broadswords == 1>><<set $Broadswords = 0>>
<</if>>You now have 2 Warhammers.<</linkreplace>>
<<linkreplace " No">>You leave the item.<</linkreplace>>

<<elseif $Warhammers == 0>>
What item do you want to drop to make room for the Warhammer?
<<if $Daggers >= 1>>
<<linkreplace " the Dagger">><<set $Daggers-->><<set $Warhammers = 1>>You drop your Dagger and gain a Warhammer.<</linkreplace>><</if>>
<<if $Spears >= 1>>
<<linkreplace " the Spear">><<set $Spears-->><<set $Warhammers = 1>>You drop your Spear and gain a Warhammer.<</linkreplace>><</if>>
<<if $Maces >= 1>>
<<linkreplace " the Mace">><<set $Maces-->><<set $Warhammers = 1>>You drop your Mace and gain a Warhammer.<</linkreplace>><</if>>
<<if $ShortSwords >= 1>>
<<linkreplace " the Short Sword">><<set $ShortSwords-->><<set $Warhammers = 1>>You drop your Short Sword and gain a Warhammer.<</linkreplace>><</if>>
<<if $Swords >= 1>>
<<linkreplace " the Sword">><<set $Swords-->><<set $Warhammers = 1>>You drop your Sword and gain a Warhammer.<</linkreplace>><</if>>
<<if $Axes >= 1>>
<<linkreplace " the Axe">><<set $Axes-->><<set $Warhammers = 1>>You drop your Axe and gain a Warhammer.<</linkreplace>><</if>>
<<if $Quarterstaffs >= 1>>
<<linkreplace " the Quarterstaff">><<set $Quarterstaffs-->><<set $Warhammers = 1>>You drop your Quarterstaff and gain a Warhammer.<</linkreplace>><</if>>
<<if $Broadswords >= 1>>
<<linkreplace " the Broadsword">><<set $Broadswords-->><<set $Warhammers = 1>>You drop your Broadsword and gain a Warhammer.<</linkreplace>><</if>>

<<linkreplace " None">>You leave your items unchanged.<</linkreplace>><</if>><</if>><</nobr>>

<<case "Sword">>
<<nobr>>
<<if $CountHands == 0>>
<<set $Swords = 1>>You pick up the Sword.<<set $CountHands++>>

<<elseif $CountHands == 1>>
<<if $Swords == 0>>
<<set $Swords = 1>>You pick up the Sword.<<set $CountHands++>>

<<elseif $Swords == 1>>You already have a Sword, do you want to pick up a spare?
<<linkreplace " Yes">><<set $Swords = 2>>You now have 2 Swords.<<set $CountHands++>><</linkreplace>>
<<linkreplace " No">>You leave the item.<</linkreplace>>
<</if>>

<<elseif $CountHands >= 2>>
<<if $Swords == 2>>You already have two Swords, your hands are full!

<<elseif $Swords == 1>>
You already have a Sword! Do you want to drop your other weapon and have 2 Swords instead?
<<linkreplace " Yes">><<set $Swords = 2>><<if $Daggers == 1>><<set $Daggers = 0>><<elseif $Spears == 1>><<set $Spears = 0>><<elseif $Maces == 1>><<set $Maces = 0>><<elseif $Warhammers == 1>><<set $Warhammers = 0>><<elseif $ShortSwords == 1>><<set $ShortSwords = 0>><<elseif $Axes == 1>><<set $Axes = 0>><<elseif $Quarterstaffs == 1>><<set $Quarterstaffs = 0>><<elseif $Broadswords == 1>><<set $Broadswords = 0>>
<</if>>You now have 2 Swords.<</linkreplace>>
<<linkreplace " No">>You leave the item.<</linkreplace>>

<<elseif $Swords == 0>>
What item do you want to drop to make room for the Sword?
<<if $Daggers >= 1>>
<<linkreplace " the Dagger">><<set $Daggers-->><<set $Swords = 1>>You drop your Dagger and gain a Sword.<</linkreplace>><</if>>
<<if $Spears >= 1>>
<<linkreplace " the Spear">><<set $Spears-->><<set $Swords = 1>>You drop your Spear and gain a Sword.<</linkreplace>><</if>>
<<if $Maces >= 1>>
<<linkreplace " the Mace">><<set $Maces-->><<set $Swords = 1>>You drop your Mace and gain a Sword.<</linkreplace>><</if>>
<<if $ShortSwords >= 1>>
<<linkreplace " the Short Sword">><<set $ShortSwords-->><<set $Swords = 1>>You drop your Short Sword and gain a Sword.<</linkreplace>><</if>>
<<if $Warhammers >= 1>>
<<linkreplace " the Warhammer">><<set $Warhammers-->><<set $Swords = 1>>You drop your Warhammer and gain a Sword.<</linkreplace>><</if>>
<<if $Axes >= 1>>
<<linkreplace " the Axe">><<set $Axes-->><<set $Swords = 1>>You drop your Axe and gain a Sword.<</linkreplace>><</if>>
<<if $Quarterstaffs >= 1>>
<<linkreplace " the Quarterstaff">><<set $Quarterstaffs-->><<set $Swords = 1>>You drop your Quarterstaff and gain a Sword.<</linkreplace>><</if>>
<<if $Broadswords >= 1>>
<<linkreplace " the Broadsword">><<set $Broadswords-->><<set $Swords = 1>>You drop your Broadsword and gain a Sword.<</linkreplace>><</if>>

<<linkreplace " None">>You leave your items unchanged.<</linkreplace>><</if>><</if>><</nobr>>

<<case "Axe">>
<<nobr>>
<<if $CountHands == 0>>
<<set $Axes = 1>>You pick up the Axe.<<set $CountHands++>>

<<elseif $CountHands == 1>>
<<if $Axes == 0>>
<<set $Axes = 1>>You pick up the Axe.<<set $CountHands++>>

<<elseif $Axes == 1>>You already have an Axe, do you want to pick up a spare?
<<linkreplace " Yes">><<set $Axes = 2>>You now have 2 Axes.<<set $CountHands++>><</linkreplace>>
<<linkreplace " No">>You leave the item.<</linkreplace>>
<</if>>

<<elseif $CountHands >= 2>>
<<if $Axes == 2>>You already have two Axes, your hands are full!

<<elseif $Axes == 1>>
You already have an Axe! Do you want to drop your other weapon and have 2 Axes instead?
<<linkreplace " Yes">><<set $Axes = 2>><<if $Daggers == 1>><<set $Daggers = 0>><<elseif $Spears == 1>><<set $Spears = 0>><<elseif $Maces == 1>><<set $Maces = 0>><<elseif $Warhammers == 1>><<set $Warhammers = 0>><<elseif $ShortSwords == 1>><<set $ShortSwords = 0>><<elseif $Swords == 1>><<set $Swords = 0>><<elseif $Quarterstaffs == 1>><<set $Quarterstaffs = 0>><<elseif $Broadsword == 1>><<set $Broadsword = 0>>
<</if>>You now have 2 Axes.<</linkreplace>>
<<linkreplace " No">>You leave the item.<</linkreplace>>

<<elseif $Axes == 0>>
What item do you want to drop to make room for the Axe?
<<if $Daggers >= 1>>
<<linkreplace " the Dagger">><<set $Daggers-->><<set $Axes = 1>>You drop your Dagger and gain an Axe.<</linkreplace>><</if>>
<<if $Spears >= 1>>
<<linkreplace " the Spear">><<set $Spears-->><<set $Axes = 1>>You drop your Spear and gain an Axe.<</linkreplace>><</if>>
<<if $Maces >= 1>>
<<linkreplace " the Mace">><<set $Maces-->><<set $Axes = 1>>You drop your Mace and gain an Axe.<</linkreplace>><</if>>
<<if $ShortSwords >= 1>>
<<linkreplace " the Short Sword">><<set $ShortSwords-->><<set $Axes = 1>>You drop your Short Sword and gain an Axe.<</linkreplace>><</if>>
<<if $Warhammers >= 1>>
<<linkreplace " the Warhammer">><<set $Warhammers-->><<set $Axes = 1>>You drop your Warhammer and gain an Axe.<</linkreplace>><</if>>
<<if $Swords >= 1>>
<<linkreplace " the Sword">><<set $Swords-->><<set $Axes = 1>>You drop your Sword and gain an Axe.<</linkreplace>><</if>>
<<if $Quarterstaffs >= 1>>
<<linkreplace " the Quarterstaff">><<set $Quarterstaffs-->><<set $Axes = 1>>You drop your Quarterstaff and gain an Axe.<</linkreplace>><</if>>
<<if $Broadsword >= 1>>
<<linkreplace " the Broadsword">><<set $Broadsword-->><<set $Axes = 1>>You drop your Broadsword and gain an Axe.<</linkreplace>><</if>>

<<linkreplace " None">>You leave your items unchanged.<</linkreplace>><</if>><</if>><</nobr>>

<<case "Quarterstaff">>
<<nobr>>
<<if $CountHands == 0>>
<<set $Quarterstaffs = 1>>You pick up the Quarterstaff.<<set $CountHands++>>

<<elseif $CountHands == 1>>
<<if $Quarterstaffs == 0>>
<<set $Quarterstaffs = 1>>You pick up the Quarterstaff.<<set $CountHands++>>

<<elseif $Quarterstaffs == 1>>You already have a Quarterstaff, do you want to pick up a spare?
<<linkreplace " Yes">><<set $Quarterstaffs = 2>>You now have 2 Quarterstaffs.<<set $CountHands++>><</linkreplace>>
<<linkreplace " No">>You leave the item.<</linkreplace>>
<</if>>

<<elseif $CountHands >= 2>>
<<if $Quarterstaffs == 2>>You already have two Quarterstaffs, your hands are full!

<<elseif $Quarterstaffs == 1>>
You already have a Quarterstaff! Do you want to drop your other weapon and have 2 Quarterstaffs instead?
<<linkreplace " Yes">><<set $Quarterstaffs = 2>><<if $Daggers == 1>><<set $Daggers = 0>><<elseif $Spears == 1>><<set $Spears = 0>><<elseif $Maces == 1>><<set $Maces = 0>><<elseif $Warhammers == 1>><<set $Warhammers = 0>><<elseif $ShortSwords == 1>><<set $ShortSwords = 0>><<elseif $Swords == 1>><<set $Swords = 0>><<elseif $Axes == 1>><<set $Axes = 0>><<elseif $Broadsword == 1>><<set $Broadsword = 0>>
<</if>>You now have 2 Quarterstaffs.<</linkreplace>>
<<linkreplace " No">>You leave the item.<</linkreplace>>

<<elseif $Quarterstaffs == 0>>
What item do you want to drop to make room for the Quarterstaff?
<<if $Daggers >= 1>>
<<linkreplace " the Dagger">><<set $Daggers-->><<set $Quarterstaffs = 1>>You drop your Dagger and gain a Quarterstaff.<</linkreplace>><</if>>
<<if $Spears >= 1>>
<<linkreplace " the Spear">><<set $Spears-->><<set $Quarterstaffs = 1>>You drop your Spear and gain a Quarterstaff.<</linkreplace>><</if>>
<<if $Maces >= 1>>
<<linkreplace " the Mace">><<set $Maces-->><<set $Quarterstaffs = 1>>You drop your Mace and gain aQuarterstaff.<</linkreplace>><</if>>
<<if $ShortSwords >= 1>>
<<linkreplace " the Short Sword">><<set $ShortSwords-->><<set $Quarterstaffs = 1>>You drop your Short Sword and gain a Quarterstaff.<</linkreplace>><</if>>
<<if $Warhammers >= 1>>
<<linkreplace " the Warhammer">><<set $Warhammers-->><<set $Quarterstaffs = 1>>You drop your Warhammer and gain a Quarterstaff.<</linkreplace>><</if>>
<<if $Swords >= 1>>
<<linkreplace " the Sword">><<set $Swords-->><<set $Quarterstaffs = 1>>You drop your Sword and gain a Quarterstaff.<</linkreplace>><</if>>
<<if $Axes >= 1>>
<<linkreplace " the Axe">><<set $Axes-->><<set $Quarterstaffs = 1>>You drop your Axe and gain a Quarterstaff.<</linkreplace>><</if>>
<<if $Broadsword >= 1>>
<<linkreplace " the Broadsword">><<set $Broadsword-->><<set $Quarterstaffs = 1>>You drop your Broadsword and gain a Quarterstaff.<</linkreplace>><</if>>

<<linkreplace " None">>You leave your items unchanged.<</linkreplace>><</if>><</if>><</nobr>>

<<case "Broadsword">>
<<nobr>>
<<if $CountHands == 0>>
<<set $Broadswords = 1>>You pick up the Broadsword.<<set $CountHands++>>

<<elseif $CountHands == 1>>
<<if $Broadswords == 0>>
<<set $Broadswords = 1>>You pick up the Broadsword.<<set $CountHands++>>

<<elseif $Broadswords == 1>>You already have a Broadsword, do you want to pick up a spare?
<<linkreplace " Yes">><<set $Broadswords = 2>>You now have 2 Broadswords.<<set $CountHands++>><</linkreplace>>
<<linkreplace " No">>You leave the item.<</linkreplace>>
<</if>>

<<elseif $CountHands >= 2>>
<<if $Broadswords == 2>>You already have two Broadswords, your hands are full!

<<elseif $Broadswords == 1>>
You already have a Broadsword! Do you want to drop your other weapon and have 2 Broadswords instead?
<<linkreplace " Yes">><<set $Broadswords = 2>><<if $Daggers == 1>><<set $Daggers = 0>><<elseif $Spears == 1>><<set $Spears = 0>><<elseif $Maces == 1>><<set $Maces = 0>><<elseif $Warhammers == 1>><<set $Warhammers = 0>><<elseif $ShortSwords == 1>><<set $ShortSwords = 0>><<elseif $Swords == 1>><<set $Swords = 0>><<elseif $Axes == 1>><<set $Axes = 0>><<elseif $Quarterstaffs == 1>><<set $Quarterstaffs = 0>>
<</if>>You now have 2 Broadswords.<</linkreplace>>
<<linkreplace " No">>You leave the item.<</linkreplace>>

<<elseif $Broadswords == 0>>
What item do you want to drop to make room for the Broadsword?
<<if $Daggers >= 1>>
<<linkreplace " the Dagger">><<set $Daggers-->><<set $Broadswords = 1>>You drop your Dagger and gain a Broadsword.<</linkreplace>><</if>>
<<if $Spears >= 1>>
<<linkreplace " the Spear">><<set $Spears-->><<set $Broadswords = 1>>You drop your Spear and gain a Broadsword.<</linkreplace>><</if>>
<<if $Maces >= 1>>
<<linkreplace " the Mace">><<set $Maces-->><<set $Broadswords = 1>>You drop your Mace and gain a Broadsword.<</linkreplace>><</if>>
<<if $ShortSwords >= 1>>
<<linkreplace " the Short Sword">><<set $ShortSwords-->><<set $Broadswords = 1>>You drop your Short Sword and gain a Broadsword.<</linkreplace>><</if>>
<<if $Warhammers >= 1>>
<<linkreplace " the Warhammer">><<set $Warhammers-->><<set $Broadswords = 1>>You drop your Warhammer and gain a Broadsword.<</linkreplace>><</if>>
<<if $Swords >= 1>>
<<linkreplace " the Sword">><<set $Swords-->><<set $Broadswords = 1>>You drop your Sword and gain a Broadsword.<</linkreplace>><</if>>
<<if $Axes >= 1>>
<<linkreplace " the Axe">><<set $Axes-->><<set $Broadswords = 1>>You drop your Axe and gain a Broadsword.<</linkreplace>><</if>>
<<if $Quarterstaffs >= 1>>
<<linkreplace " the Quarterstaff">><<set $Quarterstaffs-->><<set $Broadswords = 1>>You drop your Quarterstaff and gain a Broadsword.<</linkreplace>><</if>>

<<linkreplace " None">>You leave your items unchanged.<</linkreplace>><</if>><</if>><</nobr>>

<<case "Health Potion">>
<<nobr>>
<<set _freespace = 8 - $CountBackpack>>

<<if $founditem[1] <= _freespace>>
<<set $HealthPotions = $HealthPotions + $founditem[1]>>You now have $HealthPotions Health Potions.<<set $CountBackpack = ($CountBackpack + $founditem[1])>>

<<elseif $founditem[1] > _freespace>>
You don't have room for that many items. Do you want to...Drop some of the items you are carrying?

<span id="dropitems1">
<<if $MealOfLaumspur > 0>>How many Meals of Laumspur do you want to drop?
<<if $MealOfLaumspur >= 1>><<link " One">><<set $MealOfLaumspur = $MealOfLaumspur - 1>><<set $CountBackpack = $CountBackpack - 1>><<replace #dropitems1>>You drop 1 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 2>><<link " Two">><<set $MealOfLaumspur = $MealOfLaumspur - 2>><<set $CountBackpack = $CountBackpack - 2>><<replace #dropitems1>>You drop 2 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 3>><<link " Three">><<set $MealOfLaumspur = $MealOfLaumspur - 3>><<set $CountBackpack = $CountBackpack - 3>><<replace #dropitems1>>You drop 3 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 4>><<link " Four">><<set $MealOfLaumspur = $MealOfLaumspur - 4>><<set $CountBackpack = $CountBackpack - 4>><<replace #dropitems1>>You drop 4 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 5>><<link " Five">><<set $MealOfLaumspur = $MealOfLaumspur - 5>><<set $CountBackpack = $CountBackpack - 5>><<replace #dropitems1>>You drop 5 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 6>><<link " Six">><<set $MealOfLaumspur = $MealOfLaumspur - 6>><<set $CountBackpack = $CountBackpack - 6>><<replace #dropitems1>>You drop 6 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 7>><<link " Seven">><<set $MealOfLaumspur = $MealOfLaumspur - 7>><<set $CountBackpack = $CountBackpack - 7>><<replace #dropitems1>>You drop 7 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 8>><<link " Eight">><<set $MealOfLaumspur = $MealOfLaumspur - 8>><<set $CountBackpack = $CountBackpack - 8>><<replace #dropitems1>>You drop 8 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
</span>

<span id="dropitems2">
<<if $StrengthPotion > 0>>How many Strength Potions do you want to drop?
<<if $StrengthPotion >= 1>><<link " One">><<set $StrengthPotion = $StrengthPotion - 1>><<set $CountBackpack = $CountBackpack - 1>><<replace #dropitems2>>You drop 1 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $StrengthPotion >= 2>><<link " Two">><<set $StrengthPotion = $StrengthPotion - 2>><<set $CountBackpack = $CountBackpack - 2>><<replace #dropitems2>>You drop 2 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $StrengthPotion >= 3>><<link " Three">><<set $StrengthPotion = $StrengthPotion - 3>><<set $CountBackpack = $CountBackpack - 3>><<replace #dropitems2>>You drop 3 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $StrengthPotion >= 4>><<link " Four">><<set $StrengthPotion = $StrengthPotion - 4>><<set $CountBackpack = $CountBackpack - 4>><<replace #dropitems2>>You drop 4 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $StrengthPotion >= 5>><<link " Five">><<set $StrengthPotion = $StrengthPotion - 5>><<set $CountBackpack = $CountBackpack - 5>><<replace #dropitems2>>You drop 5 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $StrengthPotion >= 6>><<link " Six">><<set $StrengthPotion = $StrengthPotion - 6>><<set $CountBackpack = $CountBackpack - 6>><<replace #dropitems2>>You drop 6 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $StrengthPotion >= 7>><<link " Seven">><<set $StrengthPotion = $StrengthPotion - 7>><<set $CountBackpack = $CountBackpack - 7>><<replace #dropitems2>>You drop 7 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>
<<if $StrengthPotion >= 8>><<link " Eight">><<set $StrengthPotion = $StrengthPotion - 8>><<set $CountBackpack = $CountBackpack - 8>><<replace #dropitems2>>You drop 8 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<</if>><</if>></span>

<span id="qtypickup">Do you want to pick up only some of the Health Potions?
<<if _freespace >= 1>><<link " One">><<set $HealthPotions = $HealthPotions + 1>><<set $CountBackpack = $CountBackpack + 1>><<replace #qtypickup>>You pick up 1 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 2>><<link " Two">><<set $HealthPotions = $HealthPotions + 2>><<set $CountBackpack = $CountBackpack + 2>><<replace #qtypickup>>You pick up 2 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 3>><<link " Three">><<set $HealthPotions = $HealthPotions + 3>><<set $CountBackpack = $CountBackpack + 3>><<replace #qtypickup>>You pick up 3 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 4>><<link " Four">><<set $HealthPotions = $HealthPotions + 4>><<set $CountBackpack = $CountBackpack + 4>><<replace #qtypickup>>You pick up 4 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 5>><<link " Five">><<set $HealthPotions = $HealthPotions + 5>><<set $CountBackpack = $CountBackpack + 5>><<replace #qtypickup>>You pick up 5 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 6>><<link " Six">><<set $HealthPotions = $HealthPotions + 6>><<set $CountBackpack = $CountBackpack + 6>><<replace #qtypickup>>You pick up 6 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 7>><<link " Seven">><<set $HealthPotions = $HealthPotions + 7>><<set $CountBackpack = $CountBackpack + 7>><<replace #qtypickup>>You pick up 7 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 8>><<link " Eight">><<set $HealthPotions = $HealthPotions + 8>><<set $CountBackpack = $CountBackpack + 8>><<replace #qtypickup>>You pick up 8 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
</span><</nobr>>

<<case "Health Potion">>
<<nobr>>
<<set _freespace = 8 - $CountBackpack>>

<<if $founditem[1] <= _freespace>>
<<set $HealthPotions = $HealthPotions + $founditem[1]>>You now have $HealthPotions Health Potions.<<set $CountBackpack = ($CountBackpack + $founditem[1])>>

<<elseif $founditem[1] > _freespace>>
You don't have room for that many items. Do you want to...Drop some of the items you are carrying?

<span id="dropitems1">
<<if $MealOfLaumspur > 0>>How many Meals of Laumspur do you want to drop?
<<if $MealOfLaumspur >= 1>><<link " One">><<set $MealOfLaumspur = $MealOfLaumspur - 1>><<set $CountBackpack = $CountBackpack - 1>><<replace #dropitems1>>You drop 1 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 2>><<link " Two">><<set $MealOfLaumspur = $MealOfLaumspur - 2>><<set $CountBackpack = $CountBackpack - 2>><<replace #dropitems1>>You drop 2 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 3>><<link " Three">><<set $MealOfLaumspur = $MealOfLaumspur - 3>><<set $CountBackpack = $CountBackpack - 3>><<replace #dropitems1>>You drop 3 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 4>><<link " Four">><<set $MealOfLaumspur = $MealOfLaumspur - 4>><<set $CountBackpack = $CountBackpack - 4>><<replace #dropitems1>>You drop 4 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 5>><<link " Five">><<set $MealOfLaumspur = $MealOfLaumspur - 5>><<set $CountBackpack = $CountBackpack - 5>><<replace #dropitems1>>You drop 5 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 6>><<link " Six">><<set $MealOfLaumspur = $MealOfLaumspur - 6>><<set $CountBackpack = $CountBackpack - 6>><<replace #dropitems1>>You drop 6 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 7>><<link " Seven">><<set $MealOfLaumspur = $MealOfLaumspur - 7>><<set $CountBackpack = $CountBackpack - 7>><<replace #dropitems1>>You drop 7 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 8>><<link " Eight">><<set $MealOfLaumspur = $MealOfLaumspur - 8>><<set $CountBackpack = $CountBackpack - 8>><<replace #dropitems1>>You drop 8 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
</span>

<span id="dropitems2">
<<if $StrengthPotion > 0>>How many Strength Potions do you want to drop?
<<if $StrengthPotion >= 1>><<link " One">><<set $StrengthPotion = $StrengthPotion - 1>><<set $CountBackpack = $CountBackpack - 1>><<replace #dropitems2>>You drop 1 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $StrengthPotion >= 2>><<link " Two">><<set $StrengthPotion = $StrengthPotion - 2>><<set $CountBackpack = $CountBackpack - 2>><<replace #dropitems2>>You drop 2 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $StrengthPotion >= 3>><<link " Three">><<set $StrengthPotion = $StrengthPotion - 3>><<set $CountBackpack = $CountBackpack - 3>><<replace #dropitems2>>You drop 3 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $StrengthPotion >= 4>><<link " Four">><<set $StrengthPotion = $StrengthPotion - 4>><<set $CountBackpack = $CountBackpack - 4>><<replace #dropitems2>>You drop 4 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $StrengthPotion >= 5>><<link " Five">><<set $StrengthPotion = $StrengthPotion - 5>><<set $CountBackpack = $CountBackpack - 5>><<replace #dropitems2>>You drop 5 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $StrengthPotion >= 6>><<link " Six">><<set $StrengthPotion = $StrengthPotion - 6>><<set $CountBackpack = $CountBackpack - 6>><<replace #dropitems2>>You drop 6 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $StrengthPotion >= 7>><<link " Seven">><<set $StrengthPotion = $StrengthPotion - 7>><<set $CountBackpack = $CountBackpack - 7>><<replace #dropitems2>>You drop 7 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>
<<if $StrengthPotion >= 8>><<link " Eight">><<set $StrengthPotion = $StrengthPotion - 8>><<set $CountBackpack = $CountBackpack - 8>><<replace #dropitems2>>You drop 8 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<</if>><</if>></span>


<span id="qtypickup">Do you want to pick up only some of the Health Potions?
<<if _freespace >= 1>><<link " One">><<set $HealthPotions = $HealthPotions + 1>><<set $CountBackpack = $CountBackpack + 1>><<replace #qtypickup>>You pick up 1 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 2>><<link " Two">><<set $HealthPotions = $HealthPotions + 2>><<set $CountBackpack = $CountBackpack + 2>><<replace #qtypickup>>You pick up 2 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 3>><<link " Three">><<set $HealthPotions = $HealthPotions + 3>><<set $CountBackpack = $CountBackpack + 3>><<replace #qtypickup>>You pick up 3 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 4>><<link " Four">><<set $HealthPotions = $HealthPotions + 4>><<set $CountBackpack = $CountBackpack + 4>><<replace #qtypickup>>You pick up 4 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 5>><<link " Five">><<set $HealthPotions = $HealthPotions + 5>><<set $CountBackpack = $CountBackpack + 5>><<replace #qtypickup>>You pick up 5 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 6>><<link " Six">><<set $HealthPotions = $HealthPotions + 6>><<set $CountBackpack = $CountBackpack + 6>><<replace #qtypickup>>You pick up 6 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 7>><<link " Seven">><<set $HealthPotions = $HealthPotions + 7>><<set $CountBackpack = $CountBackpack + 7>><<replace #qtypickup>>You pick up 7 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 8>><<link " Eight">><<set $HealthPotions = $HealthPotions + 8>><<set $CountBackpack = $CountBackpack + 8>><<replace #qtypickup>>You pick up 8 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
</span><</nobr>>


<<case "Health Potion">>
<<nobr>>
<<set _freespace = 8 - $CountBackpack>>

<<if $founditem[1] <= _freespace>>
<<set $HealthPotions = $HealthPotions + $founditem[1]>>You now have $HealthPotions Health Potions.<<set $CountBackpack = ($CountBackpack + $founditem[1])>>

<<elseif $founditem[1] > _freespace>>
You don't have room for that many items. Do you want to...Drop some of the items you are carrying?

<span id="dropitems1">
<<if $MealOfLaumspur > 0>>How many Meals of Laumspur do you want to drop?
<<if $MealOfLaumspur >= 1>><<link " One">><<set $MealOfLaumspur = $MealOfLaumspur - 1>><<set $CountBackpack = $CountBackpack - 1>><<replace #dropitems1>>You drop 1 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 2>><<link " Two">><<set $MealOfLaumspur = $MealOfLaumspur - 2>><<set $CountBackpack = $CountBackpack - 2>><<replace #dropitems1>>You drop 2 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 3>><<link " Three">><<set $MealOfLaumspur = $MealOfLaumspur - 3>><<set $CountBackpack = $CountBackpack - 3>><<replace #dropitems1>>You drop 3 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 4>><<link " Four">><<set $MealOfLaumspur = $MealOfLaumspur - 4>><<set $CountBackpack = $CountBackpack - 4>><<replace #dropitems1>>You drop 4 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 5>><<link " Five">><<set $MealOfLaumspur = $MealOfLaumspur - 5>><<set $CountBackpack = $CountBackpack - 5>><<replace #dropitems1>>You drop 5 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 6>><<link " Six">><<set $MealOfLaumspur = $MealOfLaumspur - 6>><<set $CountBackpack = $CountBackpack - 6>><<replace #dropitems1>>You drop 6 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 7>><<link " Seven">><<set $MealOfLaumspur = $MealOfLaumspur - 7>><<set $CountBackpack = $CountBackpack - 7>><<replace #dropitems1>>You drop 7 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 8>><<link " Eight">><<set $MealOfLaumspur = $MealOfLaumspur - 8>><<set $CountBackpack = $CountBackpack - 8>><<replace #dropitems1>>You drop 8 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
</span>

<span id="dropitems2">
<<if $StrengthPotion > 0>>How many Strength Potions do you want to drop?
<<if $StrengthPotion >= 1>><<link " One">><<set $StrengthPotion = $StrengthPotion - 1>><<set $CountBackpack = $CountBackpack - 1>><<replace #dropitems2>>You drop 1 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $StrengthPotion >= 2>><<link " Two">><<set $StrengthPotion = $StrengthPotion - 2>><<set $CountBackpack = $CountBackpack - 2>><<replace #dropitems2>>You drop 2 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $StrengthPotion >= 3>><<link " Three">><<set $StrengthPotion = $StrengthPotion - 3>><<set $CountBackpack = $CountBackpack - 3>><<replace #dropitems2>>You drop 3 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $StrengthPotion >= 4>><<link " Four">><<set $StrengthPotion = $StrengthPotion - 4>><<set $CountBackpack = $CountBackpack - 4>><<replace #dropitems2>>You drop 4 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $StrengthPotion >= 5>><<link " Five">><<set $StrengthPotion = $StrengthPotion - 5>><<set $CountBackpack = $CountBackpack - 5>><<replace #dropitems2>>You drop 5 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $StrengthPotion >= 6>><<link " Six">><<set $StrengthPotion = $StrengthPotion - 6>><<set $CountBackpack = $CountBackpack - 6>><<replace #dropitems2>>You drop 6 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $StrengthPotion >= 7>><<link " Seven">><<set $StrengthPotion = $StrengthPotion - 7>><<set $CountBackpack = $CountBackpack - 7>><<replace #dropitems2>>You drop 7 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>
<<if $StrengthPotion >= 8>><<link " Eight">><<set $StrengthPotion = $StrengthPotion - 8>><<set $CountBackpack = $CountBackpack - 8>><<replace #dropitems2>>You drop 8 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<</if>><</if>></span>


<span id="qtypickup">Do you want to pick up only some of the Health Potions?
<<if _freespace >= 1>><<link " One">><<set $HealthPotions = $HealthPotions + 1>><<set $CountBackpack = $CountBackpack + 1>><<replace #qtypickup>>You pick up 1 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 2>><<link " Two">><<set $HealthPotions = $HealthPotions + 2>><<set $CountBackpack = $CountBackpack + 2>><<replace #qtypickup>>You pick up 2 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 3>><<link " Three">><<set $HealthPotions = $HealthPotions + 3>><<set $CountBackpack = $CountBackpack + 3>><<replace #qtypickup>>You pick up 3 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 4>><<link " Four">><<set $HealthPotions = $HealthPotions + 4>><<set $CountBackpack = $CountBackpack + 4>><<replace #qtypickup>>You pick up 4 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 5>><<link " Five">><<set $HealthPotions = $HealthPotions + 5>><<set $CountBackpack = $CountBackpack + 5>><<replace #qtypickup>>You pick up 5 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 6>><<link " Six">><<set $HealthPotions = $HealthPotions + 6>><<set $CountBackpack = $CountBackpack + 6>><<replace #qtypickup>>You pick up 6 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 7>><<link " Seven">><<set $HealthPotions = $HealthPotions + 7>><<set $CountBackpack = $CountBackpack + 7>><<replace #qtypickup>>You pick up 7 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 8>><<link " Eight">><<set $HealthPotions = $HealthPotions + 8>><<set $CountBackpack = $CountBackpack + 8>><<replace #qtypickup>>You pick up 8 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
</span><</nobr>>

<<case "Health Potion">>
<<nobr>>
<<set _freespace = 8 - $CountBackpack>>

<<if $founditem[1] <= _freespace>>
<<set $HealthPotions = $HealthPotions + $founditem[1]>>You now have $HealthPotions Health Potions.<<set $CountBackpack = ($CountBackpack + $founditem[1])>>

<<elseif $founditem[1] > _freespace>>
You don't have room for that many items. Do you want to...Drop some of the items you are carrying?

<span id="dropitems1">
<<if $MealOfLaumspur > 0>>How many Meals of Laumspur do you want to drop?
<<if $MealOfLaumspur >= 1>><<link " One">><<set $MealOfLaumspur = $MealOfLaumspur - 1>><<set $CountBackpack = $CountBackpack - 1>><<replace #dropitems1>>You drop 1 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 2>><<link " Two">><<set $MealOfLaumspur = $MealOfLaumspur - 2>><<set $CountBackpack = $CountBackpack - 2>><<replace #dropitems1>>You drop 2 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 3>><<link " Three">><<set $MealOfLaumspur = $MealOfLaumspur - 3>><<set $CountBackpack = $CountBackpack - 3>><<replace #dropitems1>>You drop 3 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 4>><<link " Four">><<set $MealOfLaumspur = $MealOfLaumspur - 4>><<set $CountBackpack = $CountBackpack - 4>><<replace #dropitems1>>You drop 4 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 5>><<link " Five">><<set $MealOfLaumspur = $MealOfLaumspur - 5>><<set $CountBackpack = $CountBackpack - 5>><<replace #dropitems1>>You drop 5 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 6>><<link " Six">><<set $MealOfLaumspur = $MealOfLaumspur - 6>><<set $CountBackpack = $CountBackpack - 6>><<replace #dropitems1>>You drop 6 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 7>><<link " Seven">><<set $MealOfLaumspur = $MealOfLaumspur - 7>><<set $CountBackpack = $CountBackpack - 7>><<replace #dropitems1>>You drop 7 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $MealOfLaumspur >= 8>><<link " Eight">><<set $MealOfLaumspur = $MealOfLaumspur - 8>><<set $CountBackpack = $CountBackpack - 8>><<replace #dropitems1>>You drop 8 Meals of Laumspur. You now have _freespace spaces available.<</replace>><</link>><</if>>
</span>

<span id="dropitems2">
<<if $StrengthPotion > 0>>How many Strength Potions do you want to drop?
<<if $StrengthPotion >= 1>><<link " One">><<set $StrengthPotion = $StrengthPotion - 1>><<set $CountBackpack = $CountBackpack - 1>><<replace #dropitems2>>You drop 1 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $StrengthPotion >= 2>><<link " Two">><<set $StrengthPotion = $StrengthPotion - 2>><<set $CountBackpack = $CountBackpack - 2>><<replace #dropitems2>>You drop 2 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $StrengthPotion >= 3>><<link " Three">><<set $StrengthPotion = $StrengthPotion - 3>><<set $CountBackpack = $CountBackpack - 3>><<replace #dropitems2>>You drop 3 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $StrengthPotion >= 4>><<link " Four">><<set $StrengthPotion = $StrengthPotion - 4>><<set $CountBackpack = $CountBackpack - 4>><<replace #dropitems2>>You drop 4 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $StrengthPotion >= 5>><<link " Five">><<set $StrengthPotion = $StrengthPotion - 5>><<set $CountBackpack = $CountBackpack - 5>><<replace #dropitems2>>You drop 5 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $StrengthPotion >= 6>><<link " Six">><<set $StrengthPotion = $StrengthPotion - 6>><<set $CountBackpack = $CountBackpack - 6>><<replace #dropitems2>>You drop 6 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if $StrengthPotion >= 7>><<link " Seven">><<set $StrengthPotion = $StrengthPotion - 7>><<set $CountBackpack = $CountBackpack - 7>><<replace #dropitems2>>You drop 7 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>
<<if $StrengthPotion >= 8>><<link " Eight">><<set $StrengthPotion = $StrengthPotion - 8>><<set $CountBackpack = $CountBackpack - 8>><<replace #dropitems2>>You drop 8 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<</if>><</if>></span>


<span id="qtypickup">Do you want to pick up only some of the Health Potions?
<<if _freespace >= 1>><<link " One">><<set $HealthPotions = $HealthPotions + 1>><<set $CountBackpack = $CountBackpack + 1>><<replace #qtypickup>>You pick up 1 Health Potion. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 2>><<link " Two">><<set $HealthPotions = $HealthPotions + 2>><<set $CountBackpack = $CountBackpack + 2>><<replace #qtypickup>>You pick up 2 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 3>><<link " Three">><<set $HealthPotions = $HealthPotions + 3>><<set $CountBackpack = $CountBackpack + 3>><<replace #qtypickup>>You pick up 3 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 4>><<link " Four">><<set $HealthPotions = $HealthPotions + 4>><<set $CountBackpack = $CountBackpack + 4>><<replace #qtypickup>>You pick up 4 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 5>><<link " Five">><<set $HealthPotions = $HealthPotions + 5>><<set $CountBackpack = $CountBackpack + 5>><<replace #qtypickup>>You pick up 5 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 6>><<link " Six">><<set $HealthPotions = $HealthPotions + 6>><<set $CountBackpack = $CountBackpack + 6>><<replace #qtypickup>>You pick up 6 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 7>><<link " Seven">><<set $HealthPotions = $HealthPotions + 7>><<set $CountBackpack = $CountBackpack + 7>><<replace #qtypickup>>You pick up 7 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
<<if _freespace >= 8>><<link " Eight">><<set $HealthPotions = $HealthPotions + 8>><<set $CountBackpack = $CountBackpack + 8>><<replace #qtypickup>>You pick up 8 Health Potions. You now have _freespace spaces available.<</replace>><</link>><</if>>
</span><</nobr>>

<</switch>>

<<return "Go Back">>


O. M. G.
     I have written several hundred lines of code so far (well, written a part then copied and modified the rest). I'm not done yet, since everything after the weapons doesn't actually work (well, some of it does). All for about 16 items in the game.

     This is not working.

     Or, to be more accurate, the problem comes from the fact that it is working, but in the slowest, most akward, cumbersome, time-consuming way possible. I'm working way too hard at implimenting something so simple. Granted, I have added some features that I don't really need (not sure just how much weapon and backpack item-swapping the player is likely to do - there isn't really that much stuff in the book I'm converting). Still, I want to work on these extra features to learn how to do them, and to make something that I (and maybe even others) can use to write their own games (game-stories?) around.
     So as much as the OCD part of me wants to keep tinkering with the code I've been working on, I really need to step back and find a better way to write this.

What do you get when you widget?

     A <<widget>> is a way to use the normal SugarCube macros and expressions and all that stuff we've already been using - but give it it's own name and call it as if it was a macro. It's a great way to re-use code instead of copying out the long, painful way like I have been doing.
     Here's an example. Let's say we have 2 Weapons, a Dagger and an Axe. We find another Axe. We decide we want to pick it up, so our $Axes goes up to 2, and our Dagger goes down to 0. We now have 2 Axes and 0 Daggers.
     Right now, I have the lines of code that handle all this. For a Dagger, then I had to copy all that code, change a few variables, and paste it into the Axe, then I had to copy all that code, change a few variables, and paste it into the other 7 weapons. Instead, I should have made 1 block of code, as a widget, and just pass the argument of what weapon I'm picking up. Here's the code...

<<widget "GetHandItem">>You already have a $args[0]! Do you want to drop your other weapon and have 2 $args[0]s instead?
  <<linkreplace " Yes">>
    <<if $args[0] == "Dagger">> <<set $Daggers = 2>> <<elseif $Daggers == 1>> <<set $Daggers = 0>> <</if>>
<<if $args[0] == "Spear">> <<set $Spears = 2>> <<elseif $Spears == 1>> <<set $Spears = 0>> <</if>>
<<if $args[0] == "Mace">> <<set $Maces = 2>> <<elseif $Maces == 1>> <<set $Maces = 0>> <</if>>
<<if $args[0] == "ShortSword">> <<set $ShortSwords = 2>> <<elseif $ShortSwords == 1>> <<set $ShortSwords = 0>> <</if>>
<<if $args[0] == "Warhammer">> <<set $Warhammers = 2>> <<elseif $Warhammers == 1>> <<set $Warhammers = 0>> <</if>>
<<if $args[0] == "Sword">> <<set $Swords = 2>> <<elseif $Swords == 1>> <<set $Swords = 0>> <</if>>
<<if $args[0] == "Axe">> <<set $Axes = 2>> <<elseif $Axes == 1>> <<set $Axes = 0>> <</if>>
<<if $args[0] == "Quarterstaff">> <<set $Quarterstaffs = 2>> <<elseif $Quarterstaffs == 1>> <<set $Quarterstaffs = 0>> <</if>>
<<if $args[0] == "Broadsword">> <<set $Broadswords = 2>> <<elseif $Broadswords == 1>> <<set $Broadswords = 0>> <</if>>
  You now have 2 $args[0]s. <<return "Go Back">>
  <</linkreplace>>

  <<linkreplace " No">> <<return "You leave the item.">>
  <</linkreplace>>
<</widget>>


     To call the widget I just pass the argument of what item I am picking up. What's an "argument" I hear you ask? Well, basically it's any extra information that a macro (or widget (or function)) needs to do it's job. Looks like this...

<<GetHandItem "Axe", "Axes", 1>>

     <<GetHandItem is the name, “Axe” “Axes” and 1 are all arguments. Arguments get stored in an array called $args, which the widget can use to look up the info it needs (in this case, the name of the weapon and it's quantity). And remember that arrays start at 0, so $args[0] = “Axe”, $args[1]= “Axes” and $args[2] = 1.

     So with our new widget, we call it and tell it what weapon we are picking up a second of. Since we can only have 2 weapons total, it goes through all 9 types and increases the one we piced up to 2 while decreasing any others to 0. And, now we can use this one widget instead of copying all the code for all 9 weapon types like before.
     To use our widget, we just have to define it somewhere. According to the SugarCube documentation it should be a Passage with the tag “widget”. In the Twee notation I've been using, tags come after the Passage name-

: : PassageName [tags]
passage contents

funny thing though, when I made a new Passage to initialize my variables and set the tag to “widget” I got an error trying to load the Passage...


I had to put the tag in upper-case, “Widget”, for it to work...


Go figure.

     Okay, so now that I have one widget to do one part of my giant, ugly pile of steaming code, I need to see what else I can turn into a widget to cut down on the code bloat.

     One easy thing to convert to a widget is our “Change Gold” Passage. We were including it to change the amount of gold the player had, but we could also just define it as a widget, like this...

<<widget AddRemGold>> <<nobr>>/*
* This widget will change the player's amount of gold crowns
* [variable: $Gold] to a maximum of 50 and a minimum of 0.
* Usage: <<AddRemGold add/rem #>> the first argument is
* weather to add or remove the amount in the second argument.
*/

<<if $args[0] == "add">>

<<linkreplace "You see $args[1] Gold Crowns.">>
You pick up $args[1] Gold Crowns,
<<set $Gold = $Gold + $args[1]>>
<<if $Gold > 50>>
<<set $Gold = 50>>
but your Belt Pouch only holds 50 Gold Crowns,
<</if>>
you now have $Gold Gold Crowns.
<</linkreplace>>

<<elseif $args[0] == "rem">>

<<linkreplace "You lose $args[1] Gold Crowns.">>
You have lost $args[1] Gold Crowns,
<<set $Gold = $Gold - $args[1]>>
<<if $Gold < 0>> <<set $Gold = 0>> <</if>>
you now have $Gold Gold Crowns.
<</linkreplace>>
<<else>> There has been an error in calling this widget! The first argument must be //add// to increase gold or //rem// to decrease gold!

<</if>> <</nobr>> <</widget>>


     Now, the code here is basically the same from the Passage. One benefit is that this widget gets rid of the “You lost -10 Gold” output that the Passage had. You'll notice 2 sections in bold though. At the top, I added some comments (in the <<nobr>> so they don't spawn a bunch of blanklines) to explain how the widget works - again, what seems clear now/ to me may not later/ to someone else. And at the bottom I have some “error catching” code- the forst argument has to be “add” or “rem” for the widget to work right, if it isn't then that last <<else>> will print an error message. Also, typing //word// will put that word in italics...



     Do I need an error message in my widget? I doubt it, but it doesn't hurt to always look out for errors and figure either how to prevent them or catch them - which really matters when you're writing your own widgets and code that Twine/ SugarCube's built-in editor might not know how to look for. It's like writing comments, not exacly essential to make your game work but can help with keeping it running.

     So now I have 2 widgets that I created myself, re-usable bits of code to help simplify my inventory system. They are similar to using a Passage to store code, both give you a way to call one block of code from anywhere in your story and not have to re-type your work. Both are very helpful ideas to keep in mind when designing the mechanics for your game. But while working on these, I realize I need to ask myself something...

Occam's Programming Question: “Am I Over-Complicating This?”

     While working on my inventory system I have been looking at all the objects in my game: the gold, 2 armors, 9 weapons and 4 backpack items (ignoring the special items for the moment, will get to them in a second). Those have to go into one of several containers: belt pouch, worn head/ body armor, 2 weapons, 8 backpack items. My code has been tracking each item, and fitting it into the appropriate slot.
     What if I reversed that?
     Instead of having each variable I'm tracking be an item, what if my variables were the slots themselves?
     I say that because of the Special Items- in the book they do not take up any slots, you never have more than one, and you never drop or lose them. So I was waiting to talk about them for last, because I already know how to handle them - like Disciplines, with a blank array. I'll just drop them into an array, test for them when I need them, and ignore them the rest of the time. Very simple. Going over all this code though, really the helmet and chainmail waistcoat are special items too, so I can kind of forget about them.
     One of my biggest hurdles has been stuffing 9 weapons into 2 slots - so why not just have 2 variables, $weapon1 and $weapon2, and just say what weapon is in each? That gives me 2 things to check for instead of 9. Backpack items stink because while there are only 4 of them, you can have multiples of each (up to 8 total) - that's been kind of hard to track what is where. Again though, why not just make variables for $backpack1 to $backpack8, then I can just count down the list?
     I'll explore that idea next episode...

No comments:

Post a Comment