Branching NPC dialog sequences

Dialog ext

Dialog and DialogEntry create branching conversational sequences.

from bridge.extensions import Dialog, DialogEntry

DialogEntry

A single dialog node.

DialogEntry(speaker, text, answers=None, delay=None)

Dialog

Constructor

Dialog(root)

Methods

start(player) → Awaitable

Begin the dialog for a player.

stop(player)

Abort the dialog.

is_active(player) → bool

Whether the player is mid-dialog.


Example

farewell = DialogEntry("Bob", "Goodbye!", delay=3)
greeting = DialogEntry("Bob", "Hello! Want to trade?", answers=[
    ("Yes", trade_entry),
    ("No", farewell),
])
dialog = Dialog(greeting)
await dialog.start(player)