"Timed Passages": SugarCube (v2.18)

Summary

Made famous in Queers in Love at the End of the World, "Timed Passages" uses the the <<repeat>> macro to repeat while checking if the timer has reached zero. If so, the <<goto>> macro will immediately transition to another passage.

Live Example

Download: Live Example

Twee Code

:: StoryTitle
SugarCube: Timed Passages

:: StoryJavaScript[script]
UIBar.destroy();

:: Start
[[Start Timer|First Passage]]

:: Timer
<span id="countdown">The world will end in $seconds seconds.</span>
<<silently>>
    <<repeat 1s>>
        <<set $seconds to $seconds - 1>>
        <<if $seconds gt 0>>
            <<replace "#countdown">>The world will end in $seconds seconds.<</replace>>
        <<else>>
            <<replace "#countdown">><</replace>>
            <<goto "World End">>
            <<stop>>
        <</if>>
    <</repeat>>
<</silently>>

:: First Passage
<<include "Timer">>

[[Second Passage]]

:: Second Passage
<<include "Timer">>

[[First Passage]]

:: World End
The world has ended.

:: StoryInit
<<set $seconds to 10>>

Download: Twee Code

results matching ""

    No results matching ""