Appearance
sdk.navigator
Stateful one-tile movement controller. Prevents walk queue flooding, remembers temporarily blocked tiles, and suppresses immediate direction reversals that cause left/right oscillation.
lua
local M = require("sdk.navigator")Constants
Lua 5.4 has no enums — these are integer (or string) fields on the module.
| Name | Value | Summary |
|---|---|---|
opposite | OPPOSITE | Map of each direction to its opposite. |
new
function · new(opts)
Returns Navigator.
Parameters
| Name | Type | Summary |
|---|---|---|
opts | table|nil | timeout_ms=1400, block_ms=3500, reverse_guard_ms=900 |
Returns
| Type | Summary |
|---|---|
Navigator | — |
reset
method · reset()
Clear pending walk, blocks, and reverse-guard memory. Call on plan swap / logout; do not keep another cave's blocks. Does not walk-stop; the caller must halt movement.
observe
method · observe(here, now)
Call every tick before step(). Returns "moved" | "diverted" | "blocked" | "moving".
Parameters
| Name | Type | Summary |
|---|---|---|
here | Pos | — |
now | number | epoch ms |
is_moving
method · is_moving()
True while a walk packet is outstanding. step() refuses a second send until observe() clears pending. Not the same as 'standing'; diverted still clears pending.
last_direction
method · last_direction()
Last completed walk direction, or nil. Reverse guard compares against this per context. Cleared by reset(), not by a failed send.
is_blocked
method · is_blocked(p, now)
True if p is still inside its block_ms window. now==0 treats any stored block as live. Prunes first so callers need not.
blocked
method · blocked(now)
List of currently blocked tiles as positions. Order is map iteration; do not depend on it. Used by pathing to paint avoid cells.
step
method · step(me, here, dir, now, context)
Sends at most one pending walk. Same-context reverse within reverse_guard_ms is "reverse".
Parameters
| Name | Type | Summary |
|---|---|---|
me | LocalPlayer | — |
here | Pos | — |
dir | string|integer | — |
now | number | — |
context | string|nil | hunt/loot/search/... — reverse guard is per context |
Returns
| Type | Summary |
|---|---|
boolean|nil | ok |
string|nil | err one of: no player, stop, moving, blocked, reverse, walk failed |