Drivers
Stability: Stable.
The engine ticks each scene every 500 ms. What runs is resolved in this order:
tickhook — a custom loop on the mode (full imperative control). Replaces everything below.rulesblock — a declarative behaviour block on the mode, auto-run on the engine's built-in rules runtime. You never name a driver for it; arulesblock "just runs". This is how the common shapes (elimination rounds, team deathmatch, zone control) are expressed.driver = '<name>'— a named native driver a resource registered viaregisterDriver. This is the escape hatch for a shape thatrulescan't express and that you'd rather write imperatively.
A mode with none of these does not tick.
There is no menu of built-in drivers to pick from — the declarative
rulesblock is the default behaviour (elimination rounds, deathmatch, zone control), anddriver/registerDriveris the native escape hatch. For therulesmodel see the mode descriptor reference.
registerDriver
Any resource can contribute a shared native driver that other modes select by
name. This is different from a tick hook (private to one mode) — a
registered driver is reusable across modes — and from a rules block (declarative,
no code). Use it when you want imperative control of a shape that rules can't
express, packaged so several modes can opt in.
exports.engine:registerDriver(name, { tick = function(sceneId, snapshot) ... end })| Parameter | Type | Notes |
|---|---|---|
name | string | The value modes put in driver = '<name>'. |
driver | table | Must contain tick = function(sceneId, snapshot) ... end. |
- The
tickreceives a scene id and a read-only snapshot — the same convention as a mode hook — and acts through the write-exports. It does not receive the internal Scene object. - Invalid arguments are rejected with
[engine] registerDriver: need (name, { tick=function }). - On success the engine prints
[engine] driver registered: <name>. - The
tickruns at the engine's 500 ms cadence for every scene whose mode selected this driver.
exports.engine:registerDriver('mygametype', {
tick = function(sceneId, snap)
if snap.state == 'waiting' and snap.bothPresent then
exports.engine:spawnAll(sceneId, { freeze = false, alive = true })
exports.engine:setState(sceneId, 'live', 300)
exports.engine:announce(sceneId, 'engine:live')
end
-- ...scoring with snap + the write-exports...
end,
})Then a mode opts in with driver = 'mygametype'.