0 votes
by (710 points)

I tried the following, but it did not work due to syntax reasons.

<<repeat random(2,5)s>>
<<print "test">>
<</repeat>>

 

1 Answer

+1 vote
by (153k points)
selected by
 
Best answer

As explained by the <<repeat>> macro's documentation the first argument needs to be a valid CSS time unit.

NOTE: The delay that the <<repeat>> macro will use is determined at the time that it is called, using random() will not cause that delay to vary for each looping.

There are a number of ways to solve your syntax issue, two of them being:

1. Use a (temporary) variable to store a String representation of the unit you want to randomly determine.

<<set _delay to random(2,5) + 's'>>
<<repeat _delay>>
	Test!
<</repeat>>

2. Pass the argument as an expression using back-quotes.

<<repeat `random(2,5) + 's'`>>
	Hi there!
<</repeat>>

 

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.
...