Skip to main content

Script lifecycle and stopping

Bundle metadata is read before Lua starts. Lua side effects belong inside hexis.main.

local CONFIG = hexis.config.snapshot()

function hexis.main()
-- Start observations and actions here.
end

Each run owns its action handles, event subscriptions, HUD panel, and acquired client controls. A stop invalidates that ownership and starts cleanup.

Write bounded work

  • Put a finite timeout on actions and event waits.
  • Use hexis.sleep instead of a tight polling loop.
  • Use hexis.select when an action must race an event.
  • Unsubscribe when a long-lived subscription is no longer useful.
  • Treat world changes and authority loss as terminal for current evidence.

Do not implement movement, camera, attack, or GUI control as a per-tick Lua loop. Choose a typed action that owns the whole bounded task.

Stop behavior

When a run ends, Hexis cancels outstanding work, releases controls, stops workers, removes subscriptions, and clears run-owned HUD state. An irreversible operation that was already submitted can still report its submitted outcome; cleanup cannot make that side effect un-happen.