Differentiating Variables and Seconds Suffix

I’m using the latest versions of Twine and Harlowe

Okay. I’ve run into a problem with the (live:) macro again. But instead of digging into Harlowe docs, I’m going to ask my question here. This might seem stupid, but how do you differentiate a variable and the seconds suffix? For example, how would you do this? (live: $seconds s)[$seconds - 0.1)], would you put a special character between $seconds and s, or would the variable itself have to be 1s?
Regards, HouseonaTree :slightly_smiling_face:

1 Like

A little background:

1: The value passed to the (live:) macro represents the Number of milliseconds to use as a delay.

2: When you write a “number” literal that includes a suffix (like 1.5s) you’re telling the system that it needs converts that value into an actual Number before using the value. In the case of the s suffix you’re telling the system it needs to multiple the numerical part of the literal by 1000.
eg. 1.5s becomes 1500 (1.5 x 1000).

You use the (print:) macro to demonstrate this conversion. The following will output 1500.

number: (print: 1.5s)

So you achieve the outcome you simply need to multiple the number of seconds by 1000.

(live: $seconds * 1000)[$seconds - 0.1]

3: The $seconds - 0.1 content in the (live:) macro’s associated Hook will not cause value of $seconds to change, that would require the usage of a (set:) macro.

(set: $seconds to it - 0.1)

Nor will it result in a mathematical expression being preformed, you would need to use a (print:) macro for that to occur.

(print: $seconds - 0.1)

4: Changing the value of your $seconds variable will not alter the delay used by the active (live:) macro. The following code demonstrates this fact, while the current value of the variable is decreasing, the delay between each iteration of the associated hook remains 5 seconds.

(set: $seconds to 5)
(live: $seconds * 1000)[{
	(set: $seconds to it - 1)
	seconds: $seconds; elapsed time: (print: (time / 1000))s
	(if: $seconds is 0)[