Howdy, Stranger!

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

Switch out a variable (Harlowe)

edited July 2016 in Help! with 2.0
Hey guys,

I have a question in regards to the best way of doing something in Twine. I’m currently working on an inventory system. While I have a bunch of stuff done already, I want the player to be able to pick an item they have already found or bought and equip it into a slot. I have a $Head variable below as an example and you can switch out the current item and put in a new one.

At the moment I’m using the following code to achieve this. Bear in mind that in this instance “cowl” and “helm” have been set elsewhere on a different page. My first question is currently you can keep clicking “change” and the (link: part appears over and over which is not ideal. In addition when you click on an item (link: to equip into the slot I would prefer if the other (link: items created by the link-repeat disappeared or reset.

A more overarching question is although this method sort of works is there a better way to do this? A more logical way to switch out variables that I’m missing for example?
**Head** - [$Head]<head| (link-repeat: "Change")[{
        (if: $Cowl is true)[{
            (link: "Cowl")[{
                (set: $Head to "Cowl")
                    (replace: ?head)[$Head]}]}]
        (if: $Helm is true)[{
            (link: "Helm")[{
                (set: $Head to "Helm")
                    (replace: ?head)[$Head]}]}]
                    }]
Sign In or Register to comment.