Start a condition line with if followed by an expression:
if SomeGlobal.some_property >= 10 Nathan: That property is greater than or equal to 10elif SomeGlobal.some_other_property == "some value" Nathan: Or we might be in here.else Nathan: If neither are true, I'll say this.
The indented content under each condition will only execute if that condition is true.
Responses can have conditions to control when they appear:
Nathan: What would you like?- This one [if SomeGlobal.some_property == 0 or SomeGlobal.some_other_property == false /] Nathan: Ah, so you want this one?- Another one [if SomeGlobal.some_method() /] => another_label- Nothing => END
If using both a condition and a goto on a response line, the goto must come last.
Use while to create loops that repeat as long as a condition is true:
while SomeGlobal.some_property < 10 Nathan: The property is still less than 10 - specifically, it is {{SomeGlobal.some_property}}. do SomeGlobal.some_property += 1Nathan: Now, we can move on.
Be careful with while loops! Ensure the condition will eventually become false, or you’ll create an infinite loop.
if SomeGlobal.has_met_nathan == false do SomeGlobal.animate("Nathan", "Wave") Nathan: Hi, I'm Nathan. set SomeGlobal.has_met_nathan = trueNathan: What can I do for you?
The Dialogue Manager will call the animate method on the SomeGlobal object with the specified arguments.
~ startdo game.hello()do pirate()set game.pirate_name = "delilah"do debug(game.pirate_name)=> END
Extra game states provide references to objects that exist outside the dialogue system. Changes to their properties persist after the conversation ends, unlike locals which are temporary.
Here’s a complete example combining conditions and mutations:
using GameState~ startif player_health <= 0 Nathan: You don't look so good... => game_overelif player_health < 50 Nathan: You should heal up! do show_health_warning()else Nathan: You're looking healthy!Nathan: What would you like to do?- Buy health potion [if gold >= 50 and player_health < 100] set gold -= 50 set player_health = 100 do play_sound("heal") Nathan: There you go, good as new! => start- Buy weapon [if gold >= 100 and not has_weapon] set gold -= 100 set has_weapon = true Nathan: A fine weapon! => start- Leave Nathan: Safe travels! => END~ game_overNathan: This is the end for you...do trigger_game_over()=> END!