Skip to main content

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 fallback Say calls)
    • inst.components.npc_talker (for advanced Chatter calls with chatterparams support)
  • Tags: None identified.

Properties

PropertyTypeDefault ValueDescription
instEntityThe entity instance this behavior node controls.
chatlines`stringtablefunction`
chatter_timenumber?nilChatter duration (used only with npc_talker:Chatter).
chatter_forcetextstring?nilOptional forced text override for chatter.
chatter_echotochatpriority`01number?`
nextchattimenumber?0World time when the next chatter is allowed. Initialized to 0.
delaynumber?nilBase delay (in seconds) between successive chatters when child is RUNNING.
rand_delaynumber?nilRandom variance added to delay (scaled by math.random()).
enter_delaynumber?nilOptional initial delay when the node first enters RUNNING state.
enter_delay_randnumber?nilRandom 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: updates self.status, schedules future chatter, and may call Say/Chatter).

Events & Listeners

None identified.