Howdy, Stranger!

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

Using greater than/less than to make a passage choice in Harlowe

edited March 2016 in Help! with 2.0
I'm trying to make a story that branches depending on whether the player has accumulated a certain number of points. I've got it set up currently so that if the player visits specific passages, they get a point. After a series of yes/no decisions, I want their points to be evaluated, and then give them a link to one branch or the other depending on if they have enough points.

This is how I've done it so far:

In Passage 1:
(set: $points to 0)

In a passage where they earn points (but not in passages where they don't earn points):
(set: $points to it + 1)

I know this part works because I included
(print: $points)
in each passage to check.

Then, in the passage where the points are evaluated, I have:
(if: $points is >= 2)[This gets printed and there's a [[Storyline X]] link.]
(else-if: $points is < 2)[This gets printed and there's a [[Storyline Y]] link.]

However, nothing is getting printed, so the link to the next branch of the story doesn't show. I think this might be because (if:) only works with true/false? In which case, should I be using a different method? Or is there a more elegant way to use this method?

Harlowe in Twine 2.0.10.

Thanks!

ETA: In the same context, is it possible to have different links leading to the same passage, but for points to be assigned depending on which link is clicked? For example:
You can choose to [[fight with magic->Win Fight]] or to [[fight with your sword->Win Fight]].

Then, when the player arrives in the passage "Win Fight", they get points if they used magic, but they don't get points if they used a sword. Is that possible? What would it look like?

Comments

  • hkfto wrote: »
    Then, in the passage where the points are evaluated, I have:
    (if: $points is >= 2)[This gets printed and there's a [[Storyline X]] link.]
    (else-if: $points is < 2)[This gets printed and there's a [[Storyline Y]] link.]
    
    You're using two separate operators where you need exactly one. Leave off the is operator, like so:
    (if: $points >= 2)[This gets printed and there's a [[Storyline X]] link.]
    (else-if: $points < 2)[This gets printed and there's a [[Storyline Y]] link.]
    
    Also, you don't need the second conditional at all. If the first fails, then your second must be true with the logic you're using, so you may omit it. For example:
    (if: $points >= 2)[This gets printed and there's a [[Storyline X]] link.]
    (else:)[This gets printed and there's a [[Storyline Y]] link.]
    

    hkfto wrote: »
    ETA: In the same context, is it possible to have different links leading to the same passage, but for points to be assigned depending on which link is clicked? For example:
    You can choose to [[fight with magic->Win Fight]] or to [[fight with your sword->Win Fight]].
    

    Then, when the player arrives in the passage "Win Fight", they get points if they used magic, but they don't get points if they used a sword. Is that possible? What would it look like?
    Change the "fight with magic" link to something like the following:
    (link: "fight with magic")[(set: $points to it + 1)(goto: "Win Fight")]
    
  • Thanks very much! That clears up a lot.
Sign In or Register to comment.