# LocalPlayer

> Talos 0.7 · Since 0.7

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

## Signature

```ts
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

| Member | Signature | Description |
|---|---|---|
| `number` | `readonly number: number` | 1 to 4: what a game shows as "P2". |
| `device` | `readonly 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. |
| `pad` | `readonly pad: number \| null` | The pad's id when the device is a pad, else null. |
| `connected` | `readonly connected: boolean` | False while the player's pad is unplugged; the seat waits for it. |
| `entity` | `readonly entity: EntityHandle \| null` | The entity the player's devices drive, or null. |

## Example

The tested fixture `fixtures/app/agent.ts`.

```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
```
