Twine Version: 2
Story Format: Harlowe
Hi! I think this is quite an advanced one. I’ve managed to create a set-up where every time the player clicks within a certain space, it adds to their score, updates the text on the page (once the score passes a certain threshold) and fills a little bar up. This all works nicely.
However, I now want to have the player click individual words, which then disappear. I’ve got two problems – I can’t seem to combine the normal ‘link’ or ‘link-reveal’ macro with the rest of my code. Either the words disappear, or the score updates, but not both at the same time.
The other problem is I don’t want to repeat my code for every single clickable link – there’s too much of it. It’d be better if I could have each link disappear and at the same time call in a passage that runs all the code and then vanishes itself. Something like that?
At the moment, this is the code:
[(display: "UpdateScore")]<scorelogic|\
\[]<reaction|
</div>
The ‘UpdateScore’ passage which is set to display is as follows:
{[<div style="position: absolute; top: 0; left: 0; width: 100vw; height: 100vh;"></div>]<link|(click: ?link)[
(if: $score is 20)[(replace: ?reaction)[<div class="shake">(She raised a thuggish brow.)</div>]]
(if: $score is 50)[(replace: ?reaction)[<div class="shake">(She pinched her cuffs till they were taut.)</div>]]
(if: $score is 80)[(replace: ?reaction)[<div class="shake">(She smoothed her sails. She thumbed her ruff.)</div>]]
(if: $score > 99)[(go-to: "I'd come forearmed")]
(else:)[
(set: $score to it + 10)
(print: "<script>GE.updateScore(" + (text: $maxScore) + "," + (text: $score) + ");")
(replace: ?scorelogic)[(display: "UpdateScore")]
]
]}