Timers, parallel actions and clocks
LESSON 10
Leave time for an animation or a sound while the game continues to process frames.
local Script = {}function Script.run(context)
local values = await(Parallel(
function()
await(Wait(0.05))
return "short"
end,
function()
await(Wait(0.10))
return "long"
end
))
return tostring(values[0]) .. "/" .. tostring(values[1])
endreturn ScriptExpected result: short/long. Each branch is a function. Parallel starts the branches together and
waits for all of them. The returned Godot array keeps the original branch order. Wait takes seconds.
Use await(Wait(0.5)) between two sequential cues for a half-second pause.
A wait resumes the same invocation. A different button or scene event can run while it is waiting.
Before changing a room-specific control afterward, verify CurrentScene() and the puzzle state. For a
countdown that survives save/load, explicitly keep the remaining time or deadline in project state.
DateTimeString(true) returns a UTC timestamp for a journal. NowUnix() gives wall-clock seconds.
For measuring short performance intervals use Godot's monotonic Time:get_ticks_msec(). Calendar
changes can move wall-clock time backward.
