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?
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]]]]
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
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.
Now that I’m testing both solution, Josh and mine, in the context of a real IF work, I noticed an important difference in the results, which can be explained with the proverbial picture worth a thousand words:
(notice that the text is in Italian but don’t worry, I’ll point to the difference which matters)
With Grams’s solution, the revealed link always appears at the end of the page, and in my solution the revealed link appears at the end of the last clicked link. As one can easily notice, when the revealed text is rather long, my solution perhaps is more appropriate, not forcing the player to scroll to the end of the page (or worst, bewildering the player from the apparent lack of new links).
HTH and
Best regards from Italy,
dott. Piergiorgio.
Sure, tthat’s the tradeoff. With (rerun: ?hookToReveal) you can use the same revealed content for multiple links, but it always appears in one particular place on the page (which may or may not be the end; you can put it wherever you want). With (link-rerun:) you have to duplicate the revealed content for each link, but it will appear at the end of each individual link.
In my case, the revealed content will be different (specifically, is a CYOA equivalent of EXAMINE); but can also be, say, evidences collected in a detective story, and here your method can be useful, activating the revealed link after collecting the required # of evidences.
so, in the end, we have two complementary alternatives, which can be only good for the IF community !