Timer that starts when a hook is displayed

Twine Version: 2.7.1

I have a hook that only gets displayed after the user clicks a link. Now I want to append some text to that hook a few seconds after it has initially been displayed. I found out that I can not use the (after:) macro, since it counts the time since the passage has been entered.

So I found this solution:

|main>[You can see absolutely nothing through the porthole of the… thing you're in. Only darkness. //Stay calm//, you think, as hysterical laughter is trying to break its way from your stomach to your throat. //It's not a coffin.// Maybe there is a way to open it from the inside. You should try to find some kind of lever or button.]


{(link-rerun: "Try to call for help")[
	(append:?main)[
      {<br /><br />"Hello? Is someone there? HELP!" you shout, as you hammer against the inside of your not-coffin. "Anyone? HEEELP!!"
      (set: _time to 3)
      (live: 1s)[
        (set: _time to it -1)
        (if: _time <= 0)[
            (stop:)
            Nothing happens.
        ]
      ]}
	]
]}

Which works, but seems way to complicated to me for such a simple task. Together with the fact that this is my very first time working with Twine and Harlowe, this makes me think that I must be doing something wrong.

Is there a better (i.e.: more idiomatic and simpler) way to achieve what I want?

Instead of creating a variable to count the seconds (and have it run every second):

(set: _time to 3)
(live: 1s)[
  (set: _time to it -1)
  (if: _time <= 0)[
    (stop:)
    Nothing happens.
  ]
]

…you could use the duration parameter to simply set it to the length you want:

(live: 3s)[Nothing happens.(stop:)]

The (live:) macro should only start after it is displayed in the passage.

Let me know if that helps.

1 Like

That does indeed un-clutter it quite a bit while doing the same thing. Thanks a bunch!

1 Like