Chattynode
Overview
ChattyNode is a subclass of BehaviourNode used in behavior trees to orchestrate timed, conditional speech from an entity. It evaluates its single child node and, while the child is in RUNNING status, triggers spoken dialogue or chatter at randomly spaced intervals. It supports three modes of message delivery:
- A table of strings (legacy, host-only),
- A function returning a string (or nil),
- A string key referencing localized strings in
STRINGS.
It prioritizes npc_talker:Chatter (which supports advanced chatter parameters and networked display) over talker:Say, depending on component availability.
Dependencies & Tags
- Components used:
inst.components.talker(for fallbackSaycalls)inst.components.npc_talker(for advancedChattercalls with chatterparams support)
- Tags: None identified.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | Entity | — | The entity instance this behavior node controls. |
chatlines | `string | table | function` |
chatter_time | number? | nil | Chatter duration (used only with npc_talker:Chatter). |
chatter_forcetext | string? | nil | Optional forced text override for chatter. |
chatter_echotochatpriority | `0 | 1 | number?` |
nextchattime | number? | 0 | World time when the next chatter is allowed. Initialized to 0. |
delay | number? | nil | Base delay (in seconds) between successive chatters when child is RUNNING. |
rand_delay | number? | nil | Random variance added to delay (scaled by math.random()). |
enter_delay | number? | nil | Optional initial delay when the node first enters RUNNING state. |
enter_delay_rand | number? | nil | Random variance added to the initial delay. |
Main Functions
ChattyNode:Visit()
- Description: Main behavior node entry point. Executes the child node, updates status, and conditionally triggers speech based on timing and child state. Called each tick while the behavior tree is active.
- Parameters: None.
- Returns:
nil(side-effect only: updatesself.status, schedules future chatter, and may callSay/Chatter).
Events & Listeners
None identified.