Clicking two links to reveal a third on the same page

Twine Version: 2.7.1

I haven’t used Twine in a while, and I feel like this must be very basic, but I can’t remember how to do a certain thing. I want the player to click two links on the same page in any order, with each link increasing the same variable and the links themselves transforming into normal text. When the variable hits 2, then a third link would appear to enable the player to leave the page. Like so:

(link: “Click me.”)[Done.(set: $prepare to $prepare + 1)]
(link: “Also click me.”)[Done.(set: $prepare to $prepare + 1)]

(if: $prepare is 2)[[[All done.|next]]]

But the third “All done.” link won’t appear. Because you have to exit and return to the page, I guess? But is there a way to make it automatically appear without leaving the page?

1 Like

Twine in general makes that kind of stuff less easy than you might think, but I’m pretty sure with that version, for your case you can use (rerun:) and a named hook.

(link: "Click me.")[Done.(set: $prepare to $prepare + 1)(rerun: ?prepared)]
(link: "Also click me.")[Done.(set: $prepare to $prepare + 1)(rerun: ?prepared)]

|prepared>[(if: $prepare is 2)[[[All done.|next]]]]
(link: "Click me.")[Done.(set: $prepare to $prepare + 1)(rerun: ?prepared)]
(link: "Also click me.")[Done.(set: $prepare to $prepare + 1)(rerun: ?prepared)]
​
|prepared>[(if: $prepare is 2)[[[All done.|next]]]]
4 Likes

That seems to do the trick! Thank you very much! I struggled with this for way too long…

2 Likes

I think that is a case for link-rerun along these untested lines:

(link-rerun: "Click me.")[Done.(set: $prepare to $prepare + 1)(if: $prepare is 2)[[[All done.|next]]]]
(link-rerun: "Also click me.")[Done.(set: $prepare to $prepare + 1)(if: $prepare is 2)[[[All done.|next]]]]

(I’m damn sure that the square parens are unbalanced…)
EDIT: indeed was unbalanced (four open, three closed…) source above duly rectified, tested and work as specified by CMG :slight_smile:

BONUS: a complete worked example in twee:

:: StoryTitle
CMGtest


:: StoryData
{
  "ifid": "F72069FA-ECE2-404F-8312-D0DFE7C09D1A",
  "format": "Harlowe",
  "format-version": "3.3.9",
  "start": "Passaggio senza titolo",
  "zoom": 1
}


:: Passaggio senza titolo {"position":"100,200","size":"100,100"}
A test for CMG

<!--quick testing of my solution of a problem in int-fiction (see https://intfiction.org/t/clicking-two-links-to-reveal-a-third-on-the-same-page/7961-->

(link-rerun: "Click me.")[Done.(set: $prepare to $prepare + 1)(if: $prepare is 2)[[[All done.|next]]]]
(link-rerun: "Also click me.")[Done.(set: $prepare to $prepare + 1)(if: $prepare is 2)[[[All done.|next]]]]


:: next {"position":"300,200","size":"100,100"}
... and CMG is now happy !

<center>THE END</center>

HTH and
Best regards from Italy,
dott. Piergiorgio.