earwax.dialogue_tree module

Provides the DialogueLine and DialogueTree classes.

class earwax.dialogue_tree.DialogueLine(parent: DialogueTree, text: Optional[str] = None, sound: Optional[pathlib.Path] = None, can_show: Optional[Callable[[], bool]] = None, on_activate: Optional[Callable[[], bool]] = None, responses: List[DialogueLine] = NOTHING)

Bases: object

A line of dialogue.

Parameters:
  • parent – The dialogue tree that this line of dialogue belongs to.
  • text – The text that is shown as part of this dialogue line.
  • sound – A portion of recorded dialogue.
  • can_show

    A callable which will determine whether or not this line is visible in the conversation.

    If it returns True, this line will be shown in the list.

  • on_activate

    A callable which will be called when this line is selected from the list of lines.

    If it returns True, the conversation can continue.

  • responses – A list of responses to this line.
class earwax.dialogue_tree.DialogueTree(tracks: List[earwax.track.Track] = NOTHING)

Bases: object

A dialogue tree object.

Variables:
  • children – The top-level dialogue lines for this instance.
  • tracks – A list of tracks to play while this dialogue tree is in focus.
get_children() → List[earwax.dialogue_tree.DialogueLine]

Get a list of all the children who can be shown currently.

This method returns a list of those children for whom child.can_show() is True.