Howdy, Stranger!

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

Harlowe if syntax with link

Hi,

The action I'm trying to crests is a point-of-view character has a choice to pick up an object in one room, and then in another room (a separate passage) if the object is in hand, another link is available. I'm using a string variable to indicate if the object (a tube of toothpaste) is has been picked up.

At the top of the game (first passage) there's a definition:

<!-- Inventory setup below here: -->
set: $inv_tootpaste is "none"

In a later passage:

Maybe I should take the toothpaste? (click-append: " toothpaste?")[ This is great! It's a full tube! You never know when you might need this. (set: $inv_toothpaste to "full")]

And then a further-on passage has this if statement:

(if: $inv_toothpaste is not "none" You could throw the toothpaste at her. ->ThrowToothpaste)

But a trial of this doesn't seem to be working. How can I debug this further? Is there something obvious I am doing wrong?

Thanks -

Comments

  • The first example is missing its parenthesis and is using a comparison operator, rather than an assignment operator. It should be something like the following:
    (set: $inv_tootpaste to "none")
    


    The second example is fine, however, I'd suggest using (link-reveal:) instead, so you aren't repeating "toothpaste". For example:
    Maybe I should take the (link-reveal: "toothpaste?")[ This is great! It's a full tube! You never know when you might need this.(set: $inv_toothpaste to "full")]
    


    The third example has a misplaced closing parenthesis and is missing the square brackets of the hook. I'd also recommend not placing any leading or trailing whitespace around the components of a link, as Twine 2 will erroneously treat them as significant. It should be something like the following:
     (if: $inv_toothpaste is not "none")[ [[You could throw the toothpaste at her.->ThrowToothpaste]]]
    
  • Wow! Thanks! That's a lot of good info. I hereby promise to look harder at examples before posting rookie-level syntax questions.
  • I just noticed that I hadn't caught that your first example misspelled $inv_toothpaste as $inv_tootpaste. You'll want to correct that too, if you haven't already.
Sign In or Register to comment.