ReferenceVerse

Countdown Timer Loop

Student can write <suspends> functions using Sleep() in loops to build countdowns and repeating timers without blocking the game.

Updated
Watch the Knot — countdown-timer-loop in ~90 seconds.

The ghost ship sails into Marooned Town the exact second the billboard hits zero, and here’s the Verse loop that makes that countdown tick without freezing your game.

We use a suspends function with a loop and Sleep to pause just this task frame-by-frame, letting the rest of the island keep running while the timer drains.

We declare a suspends RunTimer method, set our TimeLeft variable, and loop to update the billboard device, sleep for one second, and decrement the time until it breaks at zero.

Reach for a suspends loop with Sleep whenever you need repeating game timers, cooldowns, or countdowns that run in the background.

countdown_device := class(creative_device):
    @editable
    Board : billboard_device = billboard_device{}
    MyText<localizes>(S:string):message = "{S}"
    RunTimer()<suspends>:void =
        var TimeLeft : int = 3
        loop:
            Board.SetText(MyText("{TimeLeft}"))
            Sleep(1.0)
            set TimeLeft -= 1
            if (TimeLeft < 0):
                break
    OnBegin<override>()<suspends>:void =
        spawn{RunTimer()}

Build your own lesson with countdown-timer-loop

Generate a personalized, compile-checked lesson grounded in this exact reference.

Build a lesson →