Linking to a new paragraph with conditions

I’m using Harlowe 3.2.2, and I’m attempting to loop the same page multiple times. The 5th time the page appears, I want the weapon im using to break. Here’s the current code.

(if:visits % 5 is 0)[[broken stick]]
You mercilessly slaughter the ants, and pocket their corpses.

(set: $ant to $ant+(a:“1”,“1”,“1”,“1”,“1”,“1”,“1”,“1”,“1”,“1”))

You have (print: $ant’s length) ant corpses.

[[Kill more|Y]]

When you click “kill more”, it loops back to the same paragraph. On the 5th time you visit the page, i want it to take the player to a new paragraph. How do I do this?


  1. Please use the toolbar’s Preformatted Text option when including code examples, it makes then easier to read and copy-n-paste, and stops the forum’s software converting Standard (straight) quote characters into invalid Typographical (curvy) quotes.

  2. Each of the (if:) family of macros ( (else-if:), (else:), and (unless:) ) needs an Associated Hook, to contain the content it effects.
    eg. (if: $variable is "value")[ effected content here... ]

  3. You can use the it keyword when trying to do an addition or subtraction to the same variable an assignment is targeting.
    eg. (set: $ant to it + (a: "1","1","1","1","1","1","1","1","1","1"))

  4. Whenever you used the term ‘paragraph’ I’m going to assume you meant Passage.

  5. Generally it is a good Idea to associate a conditional outcome directly to the selection that causes it, rather than conditionally re-directing to another Passage when the ‘current’ Passage is visited.

I’m going to assume that when you say “take the player to a new paragraph” to mean automatically transition them to the broken stick Passage, which would involve the use of the (go-to:) macro, because currently your code is trying to conditionally show a link to this Passage.

So the simplest way to fix to your existing code would be make the following change to the first line…

(if: visits % 5 is 0)[(go-to: "broken stick")]

However a better fix would be to move the condition check to be part of the link selection…

You mercilessly slaughter the ants, and pocket their corpses.

(set: $ant to it + (a: "1","1","1","1","1","1","1","1","1","1"))

You have (print: $ant's length) ant corpses.

(link: "Kill more")[{
	(if: visits % 5 is 4)[(go-to: "broken stick")]
	(else:)[(go-to: "Y")]