Howdy, Stranger!

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

twine2/Harlowe how to 'reanimate' the click:ed hook

edited November 2015 in Help! with 2.0
Hi all,
my aim is to click on the word 'count' and increase a counter thereby, so that the new number is shown.
I do not want to switch passages.
I want to stay on the passage and only replace the number of clicks.
My solution only works for the first click, afterwards the word 'count' is neither shown as link nor clickable.

This is how I tried:
(set: $counter to 0)
The word [count]<button| was clicked [$counter]<showHowMuch| times.

(click: ?button)[(set: $counter to it + 1)(replace: ?showHowMuch)[$counter]]

As I said, this works only for the first click. Any chance to 'reanimate' the count-click while staying on this passage?

A working solution with switching passages could be the following lines, but the re-rendering of the passage looks like flickering when I click fast:
::start
The word [[count->start]] was clicked $counter times.

(set: $counter to it + 1)


I would prefer the 'hooked variant' above. Any ideas?

Thank you in advance.

Comments

  • edited November 2015
    As explained in this thread (among others) you simply need to re-attach the relevant sensor macro after each Reader interaction, in your case it is a (click:) sensor macro.

    In your case the Main and Logic passages would look something like the following:

    a. Main
    (set: $counter to 0)
    |phrase>[The word [count]<button| was clicked $counter times.
    (click: ?button)[(display: "Logic")]]
    
    b. Logic
    (set: $counter to it + 1)
    (replace: ?phrase)[The word [count]<button| was clicked $counter times.
    (click: ?button)[(display: "Logic")]]
    
    note: You don't need to name your passages the same as mine, but remember to change the (display: "Logic") call in both of the above to whatever you rename the Logic passage to.
  • Thank you very much!
    Okay, so the trick is to display the passage instead of switching to (I think of it as eval or exec).
    Indeed, does not show up the flicker-like effect.
    Thank you very much for that clear answer!
Sign In or Register to comment.