What is the proper syntax for setting things to appear on a timer?

0 votes
asked Jan 2 by Copyright_Invalid (560 points)
I've tried using timers before, but they always fail. I still have yet to set up a working timer.

1 Answer

0 votes
answered Jan 2 by greyelf (76,130 points)

There are a number of ways you can cause "things" to appear using a (live:) macro, which you use can depend on what exactly that "thing" is. And your question is a little vague on exactly what "things" you are talking about in this case.

I will assume you are trying to make some hidden text appear after 3 seconds, although this same technique can be used to reveal other "things".

Some text
|hidden)[Some hidden text
]\
Some more text

(live: 3s)[\
	(show: ?hidden)
	(stop:)
]

... the above example uses the following:

a. Hidden (named) Hook Markup to initially hide the relevant text. 

b. A (live:) macro with a 3s (3 second) delay.

c. A (show:) macro to reveal the contents of the relevant named hook.

d. A (stop:) macro to cause the execution of the live macro's associated hook to occur only a single time.

note: You can change the name of the Hidden Hook to something other than the hidden I used as long as you remember to also change the hook name passed to the related (show:) macro.

commented Jan 2 by Copyright_Invalid (560 points)
Okay, uh, wow...

That's way to much code for what I was going to use it for, more code then text actually...

Thanks anyways, I'm sure I can find a use for this in the future, so your struggle was not in vain.
commented Jan 2 by Copyright_Invalid (560 points)

But wait, couldn't I just do

(live: 3s)[hiddentext]

Or is that what I've been doing wrong?

commented Jan 2 by greyelf (76,130 points)

Yes, you could do that but you need to include a (stop:) macro in the associated hook to stop the (live:) macro re-displaying the same text every 3 seconds until the Reader moves to another passage.

(live: 3s)[hiddentext (stop:)]

The downsides of doing it this way are:

a. You have less control on the extract positioning of the hidden text within the over all page.

b. It becomes an issue if you want multiple hidden things within the same Passage, because each (live:) macro in a passage creates it's own timer thread handler and each of these handlers interfere with the Readers ability to interact with the page.

eg. to reveal two things at the same time.

The quick|hidden)[ brown] fox jumbed over the|hidden)[ lazy] dog.

(live: 3s)[{
	(show: ?hidden)
	(stop:)
}]

eg. to reveal two things, one after another.

The quick|fox)[ brown] fox jumbed over the|dog)[ lazy] dog.

(set: $counter to 0)
(live: 2s)[\
	(set: $counter to it + 1)
	(if: $counter is 1)[
		(show: ?fox)
	]
	(else-if: $counter is 2)[
		(show: ?dog)
		(stop:)
	]
]

Like I originally stated, it greatly depend on exactly what "things" you are trying to reveal.

Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.
...