So I was feeling a bit bored, and decided to see if it was possible to implement FizzBuzz in Twine.
FizzBuzz is a programming challenge which used to be used a lot in interviews for programming jobs. The definition is
"Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”."
My first attempt used the display macro to recursively display the main passage, until a counter reached 101.
(if: $count % 15 is 0)[Fizzbuzz](elseif: $count % 3 is 0)[Fizz](elseif: $count % 5 is 0)[Buzz](else:)[$count]
(set: $count to $count + 1)
(if: $count < 101)[(display: "fizzbuzz")]
The problem was Twine has code to prevent infinite recursion which caused the program to stop after 24 iterations.
So I did a second version using the live macro to update the counter, and append the correct value to the display, every 100ms. Stopping when the counter reaches 101.
(set: $count to 1)
(live: 100ms)[(if: $count % 15 is 0)[(append: ?display)[FizzBuzz<br>]](elseif: $count % 3 is 0)[(append: ?display)[Fizz<br>]](elseif: $count % 5 is 0)[(append: ?display)[Buzz<br>]](else:)[(append: ?display)[$count<br>]](set: $count to $count + 1)(if: $count is 101)[(stop:)] ]
And this version works.
So if anyone asks if Twine can implement FizzBuzz you can answer, "Yes it can."
I've attached the working version.