Howdy, Stranger!

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

Need some help with IF statements

I'm creating a new story and decided to implement an inventory. I prefer using variables with true/false to know if the player has an item or doesn't (when they pick it up i change the variable of the item to true and continue, i don't need anything complicated).
In the beginning i want the player to choose only 2 of the 6 presented items and it all worked fine until i tried to use an IF statement in order to limit the choices to 2, this is what the code looks like:

In both cases you doubt you will be coming back to this apartment and pick 2 things that might help you further, unfortunately you can carry no more than 2:

Continue with the current items

(if: $itemcount is < 2)[(if: $gun is 0)[(link: ".38 Revolver")[set: $selecteditem to $gun)(set: $gun to 1)(goto:".38 Revolver")]]
(if: $itemcount is < 2)[(if: $backpack is 0)[(link: "Backpack")[set: $selecteditem to $backpack)(set: $backpack to 1)(goto:"Backpack")]]]
(if: $itemcount is < 2)[(if: $knife is 0)[(link: "Knife")[set: $selecteditem to $knife)(set: $knife to 1)(goto:"Knife")]]]
(if: $itemcount is < 2)[(if: $wallet is 0)[(link: "Wallet")[set: $selecteditem to $wallet)(set: $wallet to 1)(goto:"Wallet")]]]
(if: $itemcount is < 2)[(if: $multitool is 0)[(link: "MultiTool")[set: $selecteditem to $multitool)(set: $multitool to 1)(goto:"MutliTool")]]]
(if: $itemcount is < 2)[(if: $bottleofwhiskey is 0)[(link: "Bottle Of Whiskey")[set: $selecteditem to $bottleofwhiskey)(set: $bottleofwhiskey to 1)(goto:"Bottle Of Whiskey")]]]

Each of the links carries the player to a passage that adds + 1 to the $itemcount variable and tells them they picked up the item, also leading them back to this passage, at least it did until i added the (if: $itemcount is < 2), no matter what i do with the $itemcount variable it never shows the items (changing it to 0, making it > 2 then changing the initial value to 3 and the item selection - 1, nothing, it's always false.
Any thoughts on this? (NOTE: i am a beginner in both coding and twine)
Also, the format is Harlowe 1.2.1

Comments

Sign In or Register to comment.