Skip to content
Untitled Sandbox - Developer Documentation
docs/api/npc

@usbx/npc

NPCs and their dialogue

local npc = require("@usbx/npc")

npc.find

function

Finds an NPC by its Script Name.

npc.find(script_name: string) -> Npc?
example
local guide = npc.find("Guide")

Use it forgrabbing a shopkeeper or guide NPC by its Script Name so a script can control it.

script_nameScript Name of the NPC.

npc.all

function

Every NPC of the place.

npc.all() -> { Npc }
example
for _, guide in npc.all() do guide:say("Hello!") end

Use it formaking every NPC react to the same event, like a new round starting.

npc.dialogue_signal

event

Fires when an NPC dialogue reaches a Send Signal node, with the NPC, the player and the name of the Dialogue Signal. The Signal with that name, if a script defines one, fires too.

npc.dialogue_signal: Event<(Npc, Player, string)>
example
npc.dialogue_signal:connect(function(speaker, player, name) print(speaker.display_name, player.name, name) end)

Use it forgiving a quest or opening a shop when a player reaches that point in an NPC's dialogue.

↑ ↓ moveEnter openEsc close