Appearance
sdk.npc
NPC greet / say / trade / buy / sell. nearest() walks TCreatureStore and accepts only positively typed or catalog-confirmed NPCs. bank / travel pick a clerk or boat/carpet by catalog, then greet + NPC talk (mode 12). Server-side range, open trade window, and capacity still apply.
lua
local M = require("sdk.npc")Constants
Lua 5.4 has no enums — these are integer (or string) fields on the module.
| Name | Value | Summary |
|---|---|---|
range | 3 | — |
scan | 8 | — |
nearest
function · nearest(range)
Returns table|nil: npc { id, name, x, y, z, dx, dy }
Parameters
| Name | Type | Summary |
|---|---|---|
range | number|nil | Chebyshev cap; default M.range (3) |
Returns
| Type | Summary |
|---|---|
table|nil | npc { id, name, x, y, z, dx, dy } |
string|nil | err |
list
function · list(range)
NPCs within range as Player objects.
destinations
function · destinations(kind)
Known travel destinations, optionally filtered by kind.
routes
function · routes(dest, kind)
Travel hops to dest.
find
function · find(query, opts)
Find an NPC by name, id, or role.
greet
function · greet(id)
Send the official greet packet for a creature id.
say
function · say(text)
Talk to the current NPC (after greet). Do not send hi again.
trade
function · trade()
Open the NPC trade window.
tradeState
function · tradeState()
Authoritative NPC shop state from the live session. Packet acceptance and NPC text alone cannot prove that the trade window opened; TNPCTradeStorage is populated by the server NPCOffer update and cleared when the window closes. Validate every pointer/range before exposing it to callers.
isTradeOpen
function · isTradeOpen(expected_name)
True when a trade window is open, optionally matching a name.
buy
function · buy(item_id, count, opts)
Buy count of item_id. offer.sell is the price you pay.
sell
function · sell(item_id, count)
Sell count of item_id. offer.buy is what the NPC pays you.
bank
function · bank(action, amount, opts)
Banker action: withdraw/deposit/balance.
travel
function · travel(dest, opts)
Ask the current travel NPC to go to dest.
request
function · request(owner, operation, payload, opts)
Submit one direct or multi-line NPC operation through the shared broker. The ticket owns interaction/communication (and inventory for trade changes) until post-send evidence arrives or the bounded timeout expires. Identical keys coalesce, so repeated ticks cannot replay a bank/travel conversation.