Keep Onbegin Light
keep onbegin light
keep-onbegin-light in ~90 seconds.The match starts, and instead of freezing while it sets up the world, your game instantly drops players into the action while the background magic keeps running. That smooth startup happens because the initialization code never gets bogged down.
If you cram all your game loops and delays into OnBegin, it blocks everything until it finishes. By using spawn, you kick off heavy tasks in the background, keeping OnBegin light and fast so the island loads without a hitch.
We declare our spawner, then write a suspends function for our infinite loot loop. Inside OnBegin, we just wrap that function in a spawn block, letting it run in parallel while OnBegin finishes instantly.
Reach for spawn whenever you have long-running loops, timers, or delays. It keeps your game's startup light, so your players never miss a beat when they hit the shore.
shore_game := class(creative_device):
@editable Spawner : item_spawner_device = item_spawner_device{}
SpawnLoot()<suspends>:void =
loop:
Sleep(4.0)
Spawner.SpawnItem()
OnBegin<override>()<suspends>:void =
spawn{SpawnLoot()}
Build your own lesson with keep-onbegin-light
Generate a personalized, compile-checked lesson grounded in this exact reference.
Build a lesson →