Pause a script without freezing the room
BASIC IN YOUR GAME
WAIT takes seconds. A tenth of a second is 0.1. While this script waits, the game can keep drawing the room and listening for input.
FUNCTION Run()
PRINT "First chime"
WAIT 0.1
PRINT "Second chime"
RETURN "done"
END FUNCTIONThe output shows First chime, then Second chime. The script returns done after the second line. Use a longer wait when the pause should be noticeable to the player.
FUNCTION Run()
DIM ready = TRUE
WAIT UNTIL ready
RETURN "Ready"
END FUNCTIONWAIT UNTIL asks a yes-or-no question. Here ready is already true, so the result is Ready immediately. In a game, use a shared flag that a button or another event can change. A local flag set to FALSE and never changed would leave the script waiting.
A deadline the game can remember#
signal_deadline = NowUnix() + 30
remaining = Max(0, signal_deadline - NowUnix())These are two separate fragments. Declare signal_deadline as a GLOBAL Integer and use DIM remaining for the local calculation. Use the first line when the clock starts. Use the second whenever you display the seconds left. NowUnix reads the device clock, so time away from the game counts too.
