What to run as the local player moves through a zone.

Written as a @:structInit class rather than a typedef, so it is still constructed from an object literal but generates valid Lua. Haxe's Lua target treats a function-typed field of an anonymous structure as a method: it calls it with colon syntax and therefore wraps the assigned closure in a self-stripping adapter. That adapter is emitted as function(_, ...) return function(...) ... end(...) end, and calling a function literal without wrapping it in parentheses is a syntax error in Lua, so the whole script fails to parse. A @:structInit class compiles the same literal to an ordinary constructor call and the field to an ordinary variable.

Variables

@:value(null)data:Dynamic = null

Anything you want to read back inside the handlers.

@:value(0)insideIntervalMs:Int = 0

How often onInside runs, in milliseconds. 0 means every frame.

@:value(null)onEnter:(zone:Zone) ‑> Void = null

Runs once, when the player crosses in.

@:value(null)onExit:(zone:Zone) ‑> Void = null

Runs once, when the player crosses back out.

@:value(null)onInside:(zone:Zone) ‑> Void = null

Runs repeatedly while the player is inside, at insideIntervalMs. Leave that at 0 for once per frame — needed for drawing, wasteful for anything else.