ScriptErrorEvent
Since 0.6
A behavior threw, blew its budget, or was interrupted; it is disabled from frame on — unless disabled is false (a stale handle in a per-tick hook, which ends that call only).
Signature
export interface ScriptErrorEvent {
type: "script-error"
frame: number
entity: string
module: string
phase: "init" | "update" | "dispose" | "onCollision" | "onTrigger" | "onTriggerEnter" | "onTriggerExit" | "onEvent" | "listener" | "budget"
message: string
/** Measured cost of the offending call, in milliseconds. */
ms?: number
/** False when the behavior keeps running (a stale handle in a per-tick hook); absent otherwise. */
disabled?: false
}
Import: import type { ScriptErrorEvent } from "@argus/api"
Members
| Member | Signature | Description |
|---|---|---|
type | type: "script-error" | |
frame | frame: number | |
entity | entity: string | |
module | module: string | |
phase | phase: "init" | "update" | "dispose" | "onCollision" | "onTrigger" | "onTriggerEnter" | "onTriggerExit" | "onEvent" | "listener" | "budget" | |
message | message: string | |
ms | ms?: number | Measured cost of the offending call, in milliseconds. |
disabled | disabled?: false | False when the behavior keeps running (a stale handle in a per-tick hook); absent otherwise. |
Example
The tested fixture fixtures/app/agent.ts.
import type { Behavior } from "@argus/api"
// Sends a nav agent to `props.target` once, then reports arrival through ctx.state so the
// test can read it without polling the crowd directly.
export default {
init(ctx) {
ctx.state.arrived = false
ctx.nav?.goTo(ctx.props.target as [number, number, number])
},
update(ctx) {
if (ctx.nav?.arrived) ctx.state.arrived = true
},
} satisfies Behavior