User:Aspidites

Alternative Syntax for Dynamic Root Nodes
Reference:

The following proposes that rather than have a separate "START_SECTIONS" tag to dynamically determine where a conversation should begin, conditional statements added to each section. Sections that could potentially be a start section would be marked appropriately with a "START_SECTION: True" attribute. As the absence of such a tag could simply evaluate to false, sections that should not be evaluated could simply omit them.

YAML: --- NPC_NAME: Mr. NPC AVATAR_PATH: some/path/to/image DEFAULT_SECTION: friendly_greeting
 * 1) In YAML file

SECTIONS: -  ID: friendly_greeting SAY: "Hi there! Its nice to meet you." ACTIONS: -   meet: mr_npc RESPONSES: - REPLY: "Uhh, sure." GOTO: end -  ID: drunk START_SECTION: True CONDITION: "pc.status['inebriated']" SAY: "Go sleep it off buddy." RESPONSES: -  REPLY: "I don' need yar advice!" GOTO: end -  ID: continue_quest START_SECTION: True CONDITION: "pc.hasItem['some_quest_item'] and pc.hasQuest['some_quest']" SAY: "Hey, you got the item! Great job" RESPONSES: -  REPLY: "Your praise makes it all worthwhile." ACTIONS: -  give_item: some_quest_item -  complete_quest: some_quest GOTO: end

The evaluation code for the above syntax should in theory be less complicated than trying to write the code to evaluate a new tag. Python: start_sections = [section for section in dialogue.sections if section.condition is not None]

for section in start_sections: if eval(section.condition): self.start_section = section break

if self.start_section is None: self.start_section == dialogue.default_section