Howdy, Stranger!

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

Newbie question

Hi I'm trying to make a game where you have to collect hearts. I want to have responses change depending on the number of hearts gathered.

In an earlier passage I have:
You've acquired a heart
{

(set: $heart = $heart + 1)

}
In the next passage I wanted to test if it worked but it doesn't seem to show

(if: $heart = 1)[You have the heart]
(elseif: $heart < 1)[You don't have the heart.]
I've written the code based on my previous knowledge of how twine's old syntax worked but it doesn't seem to work for twine 2. Could I get some guidance on how I would write this? Sorry if this has been answered before, I tried looking for an answer but got rather confused.

Comments

  • You need to state which story format you are using as answers can be different for each one.
    Because of the format of your macros I am assuming you are using Harlowe, its documentation can be found here

    The issue is that you have used a single equals sign (=) in your (if: $heart = 1) statement, as a single equals sign means assignment so you are actually assigning the value of 1 to the $heart variable.
    In Twine 1 you could of replaced the single equals sign (=) with a double equals sign (==) but in Harlowe you will need to use an "is".

    (if: $heart is 1)[You have the heart]
    (elseif: $heart < 1)[You don't have the heart.]
  • Sorry I didn't mention the format earlier but thank you for the reply! It works beautifully now!!
Sign In or Register to comment.