Talos docs

ScriptErrorEvent

Since 0.6Changed in 0.7

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).

Plain text

Signature

export interface ScriptErrorEvent {
  type: "script-error"
  frame: number
  entity: string
  module: string
  phase: "init" | "update" | "updateAll" | "pausedUpdate" | "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

MemberSignatureDescription
typetype: "script-error"
frameframe: number
entityentity: string
modulemodule: string
phasephase: "init" | "update" | "updateAll" | "pausedUpdate" | "dispose" | "onCollision" | "onTrigger" | "onTriggerEnter" | "onTriggerExit" | "onEvent" | "listener" | "budget"
messagemessage: string
msms?: numberMeasured cost of the offending call, in milliseconds.
disableddisabled?: falseFalse 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