Howdy, Stranger!

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

Can a (live:) macro update its own cycle time?

edited March 2016 in Help! with 2.0
Tl;dr: Can I make a (live: $variable) macro which changes its own variable each cycle? If so, how?

Largely out of curiosity I want to do something like this on Harlowe:
(set: $whatever to 100)
(set: $cycleTime to 1000)
(live: $cycleTime)
[
$whatever
(set: $whatever -= 1)
(set: $cycleTime -=5)
(if: $cycleTime is 0)[(stop:)]
]  

This would create a countdown that gradually sped up if it worked. Sadly, it doesn't. The (live:) macro seemingly only checks the value it is given once (which is fair enough for most applications) so updating $cycleTime has no effect. I tried nesting one (live:) macro within another but the results were.... weird (try:
(set: $whatever to 100)
(set: $cycleTime to 1000)
(live: $cycleTime)[
(live: $cycleTime)[
$whatever
(set: $whatever -= 1)
(set: $cycleTime -=50)
(if: $cycleTime is 0)[(stop:)]
]
]

if you would like to see the weird. I have played around with various times for the top level/first macro, but the weird is persistent. I think I understand what is happening here, but it's not the behaviour I want).

So, is there a solution? It's not style-crucial, but it would be fun for some of the stuff I am working on.

Thanks for reading and for any and all responses :)

Comments

  • I guess that you are trying to use $cycleTime as a counter. It is not that. The parameter in a (live:) macro is a timer: you have to provide a time unit (500ms) and the macro is repeated again and again every period, until you (stop:).

    You can use a counter within the macro. Just use another variable, not the one you used for the macro parameter. Then you reduce that variable and check its value to (stop:) when a certain value is reached.

    http://twine2.neocities.org/#macro_live
Sign In or Register to comment.