Skip to content

NPC

The NPC object represents an NPC entity in the game world.

Functions

npc:is_valid() -> boolean

Validates the object exists in the game world. Always call this before using other methods.


npc:get_id() -> number

Returns the NPC template ID.


npc:get_position() -> table

Returns position as a table with x and y fields.

lua
local pos = npc:get_position()
-- pos.x, pos.y

npc:get_name() -> string

Returns the NPC name.


npc:distance() -> number | nil

Returns the distance from the local player to the NPC, or nil if the NPC or player is unavailable.


npc:talk() -> boolean

Attempts to talk to the NPC. Returns true if the talk request was sent, or false if the NPC is invalid, the player is unavailable, or the NPC is out of interaction range.