RivalityFX Docsrivalityfx.com ↗

Drivers

Stability: Stable.

The engine ticks each scene every 500 ms. What runs is resolved in this order:

  1. tick hook — a custom loop on the mode (full imperative control). Replaces everything below.
  2. rules block — a declarative behaviour block on the mode, auto-run on the engine's built-in rules runtime. You never name a driver for it; a rules block "just runs". This is how the common shapes (elimination rounds, team deathmatch, zone control) are expressed.
  3. driver = '<name>' — a named native driver a resource registered via registerDriver. This is the escape hatch for a shape that rules can'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 rules block is the default behaviour (elimination rounds, deathmatch, zone control), and driver/registerDriver is the native escape hatch. For the rules model 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 })
ParameterTypeNotes
namestringThe value modes put in driver = '<name>'.
drivertableMust contain tick = function(sceneId, snapshot) ... end.
  • The tick receives 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 tick runs 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'.

See also