Talos docs

LocalPlayer

Since 0.7

One local player, as ctx.players.list() reports them.

Plain text

Signature

export interface LocalPlayer {
  /** 1 to 4: what a game shows as "P2". */
  readonly number: number
  /**
   * `"keyboard"`, `"keyboard-left"`, `"keyboard-right"` or `"pad"`; `"remote"` for a player with no
   * device on this machine (`join("remote")`), whose input arrives as frames; `"all"` for the one
   * player of a scene without `meta.players`, who hears every device.
   */
  readonly device: "keyboard" | "keyboard-left" | "keyboard-right" | "pad" | "remote" | "all" | "none"
  /** The pad's id when the device is a pad, else null. */
  readonly pad: number | null
  /** False while the player's pad is unplugged; the seat waits for it. */
  readonly connected: boolean
  /** The entity the player's devices drive, or null. */
  readonly entity: EntityHandle | null
}

Import: import type { LocalPlayer } from "@argus/api"

Members

MemberSignatureDescription
numberreadonly number: number1 to 4: what a game shows as "P2".
devicereadonly device: "keyboard" | "keyboard-left" | "keyboard-right" | "pad" | "remote" | "all" | "none""keyboard", "keyboard-left", "keyboard-right" or "pad"; "remote" for a player with no device on this machine (join("remote")), whose input arrives as frames; "all" for the one player of a scene without meta.players, who hears every device.
padreadonly pad: number | nullThe pad's id when the device is a pad, else null.
connectedreadonly connected: booleanFalse while the player's pad is unplugged; the seat waits for it.
entityreadonly entity: EntityHandle | nullThe entity the player's devices drive, or null.

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