Difference between revisions of "Dialogue"

From wiki
Jump to: navigation, search
(Updated to new category.)
(Restructure page.)
Line 41: Line 41:
 
Look at the documentation around Yarn, particularly sections such as [https://github.com/thesecretlab/YarnSpinner/blob/master/Documentation/YarnSpinner-Dialogue/Usage.md this]. Do not Yarn is changing frequently and documentation might not line up with the implementation used in Staxel.
 
Look at the documentation around Yarn, particularly sections such as [https://github.com/thesecretlab/YarnSpinner/blob/master/Documentation/YarnSpinner-Dialogue/Usage.md this]. Do not Yarn is changing frequently and documentation might not line up with the implementation used in Staxel.
  
== Additional Functions ==
+
= Additional Dialogue Functions =
 
These are additional functions that Staxel offers to integrate the dialogue into the game. They range from functions that do decision making to functions which give and take items and money from the player.
 
These are additional functions that Staxel offers to integrate the dialogue into the game. They range from functions that do decision making to functions which give and take items and money from the player.
  
=== acceptQuest ===
+
== Branching Functions ==
'''Usage: <code><<acceptQuest>></code>'''
+
These functions cause the game to go to a different dialogue when a certain condition is met.
 
+
 
+
If the speaker has a quest, then give the quest to player. Also if the quest has a start item then give the player that item.
+
 
+
 
+
=== adjustReputation ===
+
'''Usage: <code><<adjustReputation 20>></code>'''
+
 
+
Parameter 1: Amount to adjust by.
+
 
+
 
+
Adjust the player's reputation by the amount specified.
+
  
  
Line 63: Line 51:
 
'''Usage: <code><<branchAchievementNotCompleted staxel.achievement.PlantCrop PlantingWait>></code>'''
 
'''Usage: <code><<branchAchievementNotCompleted staxel.achievement.PlantCrop PlantingWait>></code>'''
  
Parameter 1: Achievement code to look for. (e.g. staxel.achievement.PlantCrop)
+
Parameter 1: Code of the [[Achievements|Achievement]] you want to check. (e.g. staxel.achievement.PlantCrop)
  
 
Parameter 2: Title of the Node to move to.
 
Parameter 2: Title of the Node to move to.
  
  
When this function is hit, it will check if the selected achievement has been completed. If it has been not completed it will continue on normally. If it has been completed, then it will move to the specified node. Useful for checking for completed actions, such as the uses in the tutorial.
+
When this function is hit, it will check if the selected [[Achievements|Achievement]] has been completed. If it has been completed it will continue on normally. If it has not been completed, then it will move to the specified node.  
 +
 
 +
Useful for checking for completed actions, such as checking if the player has placed a Pet House.
  
  
Line 74: Line 64:
 
'''Usage: <code><<branchBuildingHasExisted staxel.totem.workplace.Patisserie Existed>></code>'''
 
'''Usage: <code><<branchBuildingHasExisted staxel.totem.workplace.Patisserie Existed>></code>'''
  
Parameter 1: Totem code to search for.
+
Parameter 1: Code of the [[Totems|Totem]] you want to check. (e.g. staxel.totem.workplace.Patisserie)
  
 
Parameter 2: Title of the Node to move to.
 
Parameter 2: Title of the Node to move to.
  
  
When this function is hit, it will check if the specified totem has been completed at some point (i.e Has been built). If it hasn't then continue on normally. If it has been completed, then move to the specified node. This is useful for making sure you only talk about buildings that exist or have existed. (Note: Building does need to have been built before. Just placing totem doesn't count.)
+
When this function is hit, it will check if the specified [[Totems|Totem]] has been completed at some point (i.e Has been built). If it hasn't then continue on normally. If it has been completed, then move to the specified node.  
 +
 
 +
This is useful for making sure you only talk about buildings that exist or have existed. (Note: Building does need to have been built before. Just placing totem doesn't count.)
 +
 
  
If you require that it does exist then check [[#branchValidStructureExists]].
+
''If you require that it does exist then check [[#branchValidStructureExists]].''
  
  
Line 90: Line 83:
  
 
When this function is hit, it will check if the player has unclaimed rewards. If they do, then it will head to the specified node, otherwise continues on normally.
 
When this function is hit, it will check if the player has unclaimed rewards. If they do, then it will head to the specified node, otherwise continues on normally.
 +
 +
 +
Mainly used by Farm Fan to give the player rewards. Not too useful for other players.
  
  
Line 95: Line 91:
 
'''Usage: <code><<branchPlayerCantAffordItem item staxel.item.crafting.MugOSap 1 CantAfford>></code>'''
 
'''Usage: <code><<branchPlayerCantAffordItem item staxel.item.crafting.MugOSap 1 CantAfford>></code>'''
  
Parameter 1: Can be <code>item, tilePlacer or plant</code>. Use item for items. Use tilePlacer for TileObjects or Tiles. Use plant for Seeds.
+
Parameter 1: Can be <code>item, tilePlacer, plant, recipe or clothing</code>. Use item for [[Items]]. Use tilePlacer for [[Tile|Tiles]]. Use plant for [[Plants|seeds. Use recipe for [[Recipes]] and use clothing for [[Accessory|Accessories]].
  
Parameter 2: Item/Tile/Seed code. (e.g. staxel.crop.tomato)
+
Parameter 2: Code of the thing you want to buy. (e.g. staxel.item.crafting.MugOSap)
  
Parameter 3: Title of the Node to move to.
+
Parameter 3: Number of the item you want the player to buy.
  
 +
Parameter 4: Title of the Node to move to.
  
When this function is hit, it will check if the player can afford the item. If they can then continue on normally. If they can't then move onto the specified node. This is useful for only giving an option if the player can afford it.
+
Parameter 5: (Optional) The multiplier to the price. (i.e. 2.00 to make it 2 times as expensive. 0.5 to make it half as expensive.)
 +
 
 +
 
 +
When this function is hit, it will check if the player can afford the item. If they can then continue on normally. If they can't then move onto the specified node.  
 +
 
 +
 
 +
This is useful for checking if the player can actually afford the item.  
  
  
Line 108: Line 111:
 
'''Usage: <code><<branchPlayerDoesntHaveItemOfCategory seed PlantingGive>></code>'''
 
'''Usage: <code><<branchPlayerDoesntHaveItemOfCategory seed PlantingGive>></code>'''
  
Parameter 1: Category to look for.
+
Parameter 1: Category to look for for any item in the player's inventory.
  
 
Parameter 2: Title of the Node to move to.
 
Parameter 2: Title of the Node to move to.
Line 114: Line 117:
  
 
When this function is hit, it will check if the player has an item with the specific category. If they do, continue on normally and if they don't, move to the specified node.
 
When this function is hit, it will check if the player has an item with the specific category. If they do, continue on normally and if they don't, move to the specified node.
 +
 +
 +
This is useful for checking if the player has an item that the NPC wants. (For example, check for seeds so that the tutorial can teach the player how to place them.)
  
  
Line 119: Line 125:
 
'''Usage: <code><<branchPlayerDoesntHavePlayerItem staxel.item.FarmRegistrationLetter GoodBye>></code>'''
 
'''Usage: <code><<branchPlayerDoesntHavePlayerItem staxel.item.FarmRegistrationLetter GoodBye>></code>'''
  
Parameter 1: Item code. (e.g. staxel.crop.tomato)
+
Parameter 1: Code of the [[Items|Item]] you want to check. (e.g. staxel.crop.tomato)
  
 
Parameter 2: Title of the Node to move to.
 
Parameter 2: Title of the Node to move to.
Line 127: Line 133:
  
  
=== branchQuestActive ===
+
This is useful for checking if the player has an item that the NPC wants. (For example, check for seeds so that the tutorial can teach the player how to place them.)
'''Usage: <code><<branchQuestActive CheckCompletion>></code>'''
+
  
Parameter 1: Title of the Node to move to.
 
  
 +
=== branchNoVillagerWithPersonality ===
 +
'''Usage: <code><<branchNoVillagerWithPersonality staxel.village.personality.Tomboy NoTomboy>></code>'''
  
When this function is hit, it will check if the player has this person's specific quest. If the speaker has no quest, the player doesn't have the quest, or the player does have the quest but it's for the wrong day, continue on normally. Otherwise go to the node.
+
Parameter 1: Code of the [[Villager Personalities|Villager Personality]] to search for. (e.g staxel.village.personality.Tomboy)
  
 +
Parameter 2: Title of the Node to move to.
  
=== branchQuestCompletable ===
 
'''Usage: <code><<branchQuestCompletable CompleteQuest>></code>'''
 
  
Parameter 1: Title of the Node to move to.
+
When this function is hit, it will search to see if a villager with the specified personality exists in the world. If they do, continue on normally and if they don't, move to the specified node.  
  
  
When this function is hit, it will check if the player has completed this person's specific quest. If the speaker has no quest, the player does have the quest but it's for the wrong day, or if the quest is not completeable then continue on normally. Otherwise go to the node.
+
This is useful for when you want to talk about another type of villager that may or may not be in the village.
  
  
=== branchQuestTarget ===
+
=== branchNoVillagerWithName===
'''Usage: <code><<branchQuestTarget TargetDialogue>></code>'''
+
'''Usage: <code><<branchNoVillagerWithName Leif TellRumour>></code>'''
  
Parameter 1: Title of the Node to move to.
+
Parameter 1: Name of villager to look for.
  
 +
Parameter 2: Title of the Node to move to.
  
This is specifically for delivery type quests. When this function is hit, it will check if the player has a quest for the villager and if so, check to see if the the person is the target of the quest. If the speaker has no quest for the villager or the villager is not the target then continue on normally. Otherwise go to the node.
 
  
 +
When this function is hit, it will search to see if a villager with the specified name exists in the world. If they do, continue on normally and if they don't, then move to the specified node.
  
=== branchNoVillagerWithPersonality ===
 
'''Usage: <code><<branchNoVillagerWithPersonality staxel.village.personality.Tomboy NoTomboy>></code>'''
 
  
Parameter 1: Code of the personality to search for. (e.g staxel.village.personality)
+
This is useful for when you want to talk about another specific villager that may or may not be in the village. It is probably better to use [[#branchNoVillagerWithPersonality]] as it is more specific.
 +
 
 +
 
 +
=== branchValidStructureExists ===
 +
'''Usage: <code><<branchValidStructureExists staxel.totem.AirshipLanding AirshipAvailable>></code>'''
 +
 
 +
Parameter 1: Code of the [[Totems|Totem]] you want to check. (e.g. staxel.totem.AirshipLanding)
  
 
Parameter 2: Title of the Node to move to.
 
Parameter 2: Title of the Node to move to.
  
  
When this function is hit, it will search to see if a villager with the specified personality exists in the world. If they do, continue on normally and if they don't, move to the specified node. This is useful for when you want to talk about another type of villager that may or may not be in the village.
+
When this function is hit, it will search to see if a valid totem of the type specified exists. If it does, then head to the specified node otherwise it continues on normally.  
  
  
=== branchNoVillagerWithName===
+
Useful for checking that a building actually exists, and is still existing, before going to it/ talking about it.
'''Usage: <code><<branchNoVillagerWithName Leif TellRumour>></code>'''
+
  
Parameter 1: Name of person to look for.
+
''If you want to know that the building existed at some point then head to [[#branchValidStructureExists]].''
  
Parameter 2: Title of the Node to move to.
 
  
 +
== Dialogue Control Functions ==
 +
These functions determine how the dialogue looks and feels to the player.
  
When this function is hit, it will search to see if a villager with the specified name exists in the world. If they do, continue on normally and if they don't, then move to the specified node. This is useful for when you want to talk about another specific villager that may or may not be in the village.
 
  
 +
=== lockPlayerInConversation / releasePlayerFromConversation ===
 +
'''Usage: <code><<lockPlayerInConversation>></code> or <code><<releasePlayerFromConversation>></code>'''
  
=== branchValidStructureExists ===
 
'''Usage: <code><<branchValidStructureExists staxel.totem.AirshipLanding AirshipAvailable>></code>'''
 
  
Parameter 1: Totem code to search for. (e.g. staxel.totem.AirshipLanding)
+
LockPlayerInConversation forces the player to enter into conversation mode. Conversation mode does several things;
 +
* Stop the player from moving.
 +
* Brings in the black bars
 +
* Focuses player focus onto the NPC
  
Parameter 2: Title of the Node to move to.
+
ReleasePlayerFromConversation removes conversation mode from the player. Allowing them to move off and end the conversation. A <code>[[#typewriterMode|<<typewriterMode off true true>>]]</code> should be placed with this command if <code><<typewritermode on>></code> was present.
  
 +
This is used for all dialogue that is personal to the player. (i.e. Not merchant chatter.)
  
When this function is hit, it will search to see if a valid totem of the type specified exists. If it does,  then head to node continue on normally otherwise it continues on normally. Useful for checking that a building actually exists before going to it/ talking about it.
 
  
If you want to know that the building existed at some point then head to [[#branchValidStructureExists]].
+
=== pickRandomLine ===
 +
'''Usage:
 +
<pre><<pickRandomLine>>
  
 +
This is line 1.
  
=== cancelQuest ===
+
This is line 2.
'''Usage: <code><<cancelQuest>></code>'''
+
  
 +
<<flushRandomLine>></pre>'''
  
If the player has a quest for the current speaker, then cancel that quest. Otherwise do nothing.
 
  
 +
Choose a single line, from a number of text only lines, randomly up either up to the end of the node or up to the command <<flushRandomLine>>. Used to select either a random section of text so that it doesn't repeat the same text too often.
  
=== completeQuest ===
 
'''Usage: <code><<completeQuest>></code>'''
 
  
 +
=== pickRandomPath ===
 +
'''Usage:
 +
<pre><<pickRandomPath>>
  
If the speaker has a quest, and it is completable then set the quest complete. Also give the quest reward.
+
<<NodeName1>>
 +
 
 +
<<NodeName2>>
 +
 
 +
<<flushRandomPath>></pre>'''
 +
 
 +
 
 +
Choose a single line, from a number of node names, randomly up either up to the end of the node or up to the command <<flushRandomPath>>. Used to select a random node to go to so the same section of text isn't repeated often. Less clutter, in the one node, than [[#pickRandomPath]] when dealing with larger conversations.
 +
 
 +
 
 +
=== resumeProgress ===
 +
'''Usage: <code><<resumeProgress>>>></code>'''
 +
 
 +
 
 +
Resume the last node that was saved for the current player. If there is no saved value or if saved value is the "Start" node then continue on the current node.
 +
 
 +
 
 +
=== saveProgress ===
 +
'''Usage: <code><<saveProgress>> or <<saveProgress NodeA>></code>'''
 +
 
 +
Parameter 1: The title of the node to save. (Skipping means the last node is saved.)
 +
 
 +
 
 +
This saves the current node to a variable which is then stored. Useful for when a conversation needs to be completed. (e.g. It is used in the tutorial to save the last location Farm Fan was in.)
 +
 
 +
 
 +
=== shuffleNextOptions ===
 +
'''Usage: <code><<shuffleNextOptions>></code>'''
 +
 
 +
 
 +
Make the next set of options be in a random order when shown to the player.
 +
 
 +
 
 +
=== typewriterMode ===
 +
'''Usage: <code><<typewriterMode on>> or <<typewriterMode off true true>></code>'''
 +
 
 +
Parameter 1: Turn on or off typewriter mode.
 +
 
 +
Parameter 2: (If Parameter 1 is off) Clear the message so it doesn't stay around. (Set to False to keep messages after this value)
 +
 
 +
Paremeter 3: (If Parameter 1 is off and Parameter 2 is True) Setting to True lets the current node immediately end without the need to click. (e.g Ending conversation immediately.)
 +
 
 +
 
 +
Setting the typewriter to on makes it so text is filtered out a single character at a time instead of the entire message appearing at once. Should be turned off at the end of a conversation (i.e. <<typewriterMode off true true>>) before [[#lockPlayerInConversation / releasePlayerFromConversation|releasing from conversation]].
 +
 
 +
 
 +
== Useful Functions ==
 +
These are a collection of functions that will provide useful game benefits. This includes giving items, money and other functions.
 +
 
 +
 
 +
=== adjustReputation ===
 +
'''Usage: <code><<adjustReputation 20>></code>'''
 +
 
 +
Parameter 1: Amount to adjust by.
 +
 
 +
 
 +
Adjust the player's reputation with this villager by the amount specified.
  
  
Line 206: Line 278:
 
'''Usage: <code><<emote staxel.emote.ScratchHead>></code>'''
 
'''Usage: <code><<emote staxel.emote.ScratchHead>></code>'''
  
Parameter 1: Emote code to play. (e.g. staxel.emote.ScratchHead)
+
Parameter 1: Code of the [[Emote]] you want to play. (e.g. staxel.emote.ScratchHead)
  
  
Line 215: Line 287:
 
'''Usage: <code><<giveItemToPlayerIfDoesntHave item staxel.item.tool.Hoe>></code>'''
 
'''Usage: <code><<giveItemToPlayerIfDoesntHave item staxel.item.tool.Hoe>></code>'''
  
Parameter 1: Can be <code>item, tilePlacer or plant</code>. Use item for items. Use tilePlacer for TileObjects or Tiles. Use plant for Seeds.
+
Parameter 1: Can be <code>item, tilePlacer, plant, recipe or clothing</code>. Use item for [[Items]]. Use tilePlacer for [[Tile|Tiles]]. Use plant for [[Plants|seeds. Use recipe for [[Recipes]] and use clothing for [[Accessory|Accessories]].
  
Parameter 2: Item/Tile/Seed code. (e.g. staxel.crop.tomato)
+
Parameter 2: Code of the thing you want to check and give. (e.g. staxel.item.tool.Hoe)
 +
 
 +
Parameter 3: Number of the item you want to give the player.
  
  
Line 226: Line 300:
 
'''Usage: <code><<giveItemToPlayerIfCantAfford plant staxel.crop.Tomato>></code>'''
 
'''Usage: <code><<giveItemToPlayerIfCantAfford plant staxel.crop.Tomato>></code>'''
  
Parameter 1: Can be <code>item, tilePlacer or plant</code>. Use item for items. Use tilePlacer for TileObjects or Tiles. Use plant for Seeds.
+
Parameter 1: Can be <code>item, tilePlacer, plant, recipe or clothing</code>. Use item for [[Items]]. Use tilePlacer for [[Tile|Tiles]]. Use plant for [[Plants|seeds. Use recipe for [[Recipes]] and use clothing for [[Accessory|Accessories]].
 +
 
 +
Parameter 2: Code of the thing you want to check and give. (e.g. staxel.item.tool.Hoe)
  
Parameter 2: Item/Tile/Seed code.
+
Parameter 3: Number of the item you want to give the player.
  
  
Line 262: Line 338:
 
'''Usage: <code><<loadItemBuyPrice item staxel.item.crafting.MugOSap 1 $sap>></code>'''
 
'''Usage: <code><<loadItemBuyPrice item staxel.item.crafting.MugOSap 1 $sap>></code>'''
  
Parameter 1: Can be <code>item, tilePlacer or plant</code>. Use item for items. Use tilePlacer for TileObjects or Tiles. Use plant for Seeds.
+
Parameter 1: Can be <code>item, tilePlacer, plant, recipe or clothing</code>. Use item for [[Items]]. Use tilePlacer for [[Tile|Tiles]]. Use plant for [[Plants|seeds. Use recipe for [[Recipes]] and use clothing for [[Accessory|Accessories]].
  
Parameter 2: Item/Tile/Seed code.
+
Parameter 2: Code of the thing you want to check and give. (e.g. staxel.item.tool.Hoe)
  
Parameter 3: Quantity
+
Parameter 3: Number of the item you want to give the player.
 +
 
 +
Parameter 4: The name of the variable you want to use. Should start with $.
  
Parameter 4: Target Variable.
 
  
 
Calculates the cost of the specified item and places the value into the variable specified.
 
Calculates the cost of the specified item and places the value into the variable specified.
 
 
=== loadVillageActiveQuestsInfo ===
 
'''Usage: <code><<loadVillageActiveQuestsInfo>></code>'''
 
 
Loads all the current quest givers. Each consecutive quest giver is stored in the variable "$quest_giver_i" where i is the number of the quest giver starting at 0. Also stores the number of quests in the variable "$quest_count". For use of these variables look at the barkeep's dialogue.
 
  
  
Line 282: Line 353:
 
'''Usage: <code><<loadVillagerName Cecile $c_name>></code>'''
 
'''Usage: <code><<loadVillagerName Cecile $c_name>></code>'''
  
Parameter 1: Name of character to search for.
+
Parameter 1: Name of villager to search for.
  
Parameter 2: Target Variable.
+
Parameter 2: The name of the variable you want to use. Should start with $.
  
Searches for a villager with the specified name. If that villager does exist, then it places their code name into the target variable. This is specifically for loading the right translation for the character.
+
Searches for a villager with the specified name. If that villager does exist, then it places their code name into the target variable.  
 +
 
 +
 
 +
This is used specifically for loading the right translation for the villager's name. It is probably better to use [[#loadVillagerNameForPersonality]] as it is more specific.
  
  
Line 292: Line 366:
 
'''Usage: <code><<loadVillagerNameForPersonality staxel.village.personality.Mayor $mayor_name>></code>'''
 
'''Usage: <code><<loadVillagerNameForPersonality staxel.village.personality.Mayor $mayor_name>></code>'''
  
Parameter 1: Code of the personality to search for. (e.g staxel.village.personality)
+
Parameter 1: Code of the [[Villager Personalities|Villager Personality]] to search for. (e.g staxel.village.personality.Mayor)
 +
 
 +
Parameter 2: The name of the variable you want to use. Should start with $.
  
Parameter 2: Target Variable.
 
  
 
Searches for a villager with the specified personality. If that villager does exist, then it places their name into the target variable.
 
Searches for a villager with the specified personality. If that villager does exist, then it places their name into the target variable.
  
  
=== lockPlayerInConversation / releasePlayerFromConversation ===
+
This is used specifically for loading the right translation for the villager's name.
'''Usage: <code><<lockPlayerInConversation>></code> and <code><<releasePlayerFromConversation>></code>'''
+
  
  
LockPlayerInConversation forces the player to enter into conversation mode. Conversation mode does several things;
+
=== playerPurchaseItem ===
* Stop the player from moving.
+
'''Usage: <code><<playerPurchaseItem item staxel.item.crafting.MugOSap>></code>'''
* Brings in the black bars
+
* Focuses player focus onto the NPC
+
  
 +
Parameter 1: Can be <code>item, tilePlacer, plant, recipe or clothing</code>. Use item for [[Items]]. Use tilePlacer for [[Tile|Tiles]]. Use plant for [[Plants|seeds. Use recipe for [[Recipes]] and use clothing for [[Accessory|Accessories]].
  
ReleasePlayerFromConversation removes conversation mode from the player. Allowing them to move off and end the conversation. A <code>[[#typewriterMode|<<typewriterMode off true true>>]]</code> should be placed with this command if <code><<typewritermode on>></code> was present.
+
Parameter 2: Code of the thing you want to check and give. (e.g. staxel.item.tool.Hoe)
  
 +
Parameter 3: Number of the item you want to give the player.
  
=== playerPurchaseItem ===
 
'''Usage: <code><<playerPurchaseItem item staxel.item.crafting.MugOSap>></code>'''
 
 
Parameter 1: Can be <code>item, tilePlacer or plant</code>. Use item for items. Use tilePlacer for TileObjects or Tiles. Use plant for Seeds.
 
 
Parameter 2: Item/Tile/Seed code. (e.g. staxel.crop.tomato)
 
  
 
Purchases the item if the player can afford the item.
 
Purchases the item if the player can afford the item.
  
  
=== pickRandomLine ===
+
=== moveTo ===
'''Usage:  
+
'''Usage: <code><<moveTo TavernEntrance>></code>'''
<pre><<pickRandomLine>>
+
  
This is line 1.
+
Parameter 1: Waypoint Kind to find. Can be one of: <code>Any, ChillSpot, Tutorial Spawn, NearShippingDock, NearCatalogue, Fields, Totem, Pathing, MayorsOffice, Shop, TavernEntrance, BarArea, TownSquare, ShopEntrance</code>
  
This is line 2.
 
  
<<flushRandomLine>></pre>'''
+
Move the NPC to the ''nearest'' node of the kind specified. You cannot specify any particular node, just the closest.
  
  
Choose a single line, from a number of text only lines, randomly up either up to the end of the node or up to the command <<flushRandomLine>>. Used to select either a random section of text so that it doesn't repeat the same text too often.
+
=== leadTo ===
 +
'''Usage: <code><<leadTo TavernEntrance>></code>'''
  
 +
Parameter 1: Waypoint Kind to find. Can be one of: <code>Any, ChillSpot, Tutorial Spawn, NearShippingDock, NearCatalogue, Fields, Totem, Pathing, MayorsOffice, Shop, TavernEntrance, BarArea, TownSquare, ShopEntrance</code>
  
=== pickRandomPath ===
 
'''Usage:
 
<pre><<pickRandomPath>>
 
  
<<NodeName1>>
+
Move the NPC to the nearest node of the kind specified. Stops to wave at player if they are too far away.
  
<<NodeName2>>
 
  
<<flushRandomPath>></pre>'''
+
=== removePlayerItem ===
 +
'''Usage: <code><<removePlayerItem staxel.item.FarmRegistrationLetter>></code>'''
  
 +
Parameter 1: Code of the [[Items|Item]] you want to remove. (e.g. staxel.crop.tomato)
  
Choose a single line, from a number of node names, randomly up either up to the end of the node or up to the command <<flushRandomPath>>. Used to select a random node to go to so the same section of text isn't repeated often. Less clutter than [[#pickRandomPath]] when dealing with larger conversations.
 
  
 +
Remove the item specified if the player has it. Do nothing if there is no item.
  
=== moveTo ===
 
'''Usage: <code><<moveTo TavernEntrance>></code>'''
 
  
Parameter 1: Waypoint Kind to find. Can be one of: <code>Any, ChillSpot, Tutorial Spawn, NearShippingDock, NearCatalogue, Fields, Totem, Pathing, MayorsOffice, Shop, TavernEntrance, BarArea, TownSquare, ShopEntrance</code>
+
Use this in combination with [[#branchPlayerDoesntHavePlayerItem]] to enforce that an item is needed.
  
  
Move the NPC to the nearest node of the kind specified.
+
== Quest Functions ==
 +
These functions are useful for organising quests. You will generally not have to deal with these functions unless you want to make new quests.
  
  
=== leadTo ===
+
=== acceptQuest ===
'''Usage: <code><<leadTo TavernEntrance>></code>'''
+
'''Usage: <code><<acceptQuest>></code>'''
  
Parameter 1: Waypoint Kind to find. Can be one of: <code>Any, ChillSpot, Tutorial Spawn, NearShippingDock, NearCatalogue, Fields, Totem, Pathing, MayorsOffice, Shop, TavernEntrance, BarArea, TownSquare, ShopEntrance</code>
 
  
 +
If the speaker has a quest, then activate the quest for the player. Gives the start item (i.e. Delivery Item), if needed, to the player.
  
Move the NPC to the nearest node of the kind specified. Stops to wave at player if they are too far away.
 
  
 +
=== branchQuestActive ===
 +
'''Usage: <code><<branchQuestActive CheckCompletion>></code>'''
  
=== removePlayerItem ===
+
Parameter 1: Title of the Node to move to.
'''Usage: <code><<removePlayerItem staxel.item.FarmRegistrationLetter>></code>'''
+
  
Parameter 1: Item code to remove.
 
  
 +
When this function is hit, it will check if the player has this person's specific quest. If the speaker has no quest or the player doesn't have the quest or the player does have the quest but it's for the wrong day, continue on normally. Otherwise go to the node.
  
Remove the item specified if the player has it. Do nothing if there is no item.
 
  
 +
=== branchQuestCompletable ===
 +
'''Usage: <code><<branchQuestCompletable CompleteQuest>></code>'''
  
=== resumeProgress ===
+
Parameter 1: Title of the Node to move to.
'''Usage: <code><<resumeProgress>>>></code>'''
+
  
  
Resume the last node that was saved for the current player. If there is no saved value or if saved value is the "Start" node then continue on the current node.
+
When this function is hit, it will check if the player has completed this person's specific quest. If the speaker has no quest or the player does have the quest but it's for the wrong day or if the quest is not complete-able then continue on normally. Otherwise go to the node.
  
  
=== saveProgress ===
+
=== branchQuestTarget ===
'''Usage: <code><<saveProgress>> or <<saveProgress NodeA>></code>'''
+
'''Usage: <code><<branchQuestTarget TargetDialogue>></code>'''
  
Parameter 1: The title of the node to save. (Skipping means the last node is saved.)
+
Parameter 1: Title of the Node to move to.
  
  
This saves the current node to a variable which is then stored. Useful for when a conversation needs to be completed. (e.g. It is used in the tutorial to save the last location Farm Fan was in.)
+
This is specifically for delivery type quests. When this function is hit, it will check if the player has a quest for the villager and if so, check to see if the the villager is the target of the quest. If the speaker has no quest for the villager or the villager is not the target then continue on normally. Otherwise go to the node.
  
  
=== shuffleNextOptions ===
+
=== cancelQuest ===
'''Usage: <code><<shuffleNextOptions>></code>'''
+
'''Usage: <code><<cancelQuest>></code>'''
  
  
Make the next set of options be in a random order.
+
If the player has a quest for the current speaker, then cancel that quest. Otherwise do nothing.
  
  
=== typewriterMode ===
+
=== completeQuest ===
'''Usage: <code><<typewriterMode on>> or <<typewriterMode off true true>></code>'''
+
'''Usage: <code><<completeQuest>></code>'''
  
Parameter 1: Turn on or off typewriter mode.
 
  
Parameter 2: (If Parameter 1 is off) Clear the message so it doesn't stay around. (Set to False to keep messages after this value)
+
If the speaker has a quest, and it is completable then set the quest complete. Also give the quest reward.
  
Paremeter 3: (If Parameter 1 is off and Parameter 2 is True) Setting to True lets the current node immediately end without the need to click. (e.g Ending conversation immediately.)
 
  
 +
=== loadVillageActiveQuestsInfo ===
 +
'''Usage: <code><<loadVillageActiveQuestsInfo>></code>'''
  
Setting the typewriter to on makes it so text is filtered out a single character at a time instead of the entire message appearing at once. Should be turned off at the end of a conversation (i.e. <<typewriterMode off true true>>) before [[#lockPlayerInConversation / releasePlayerFromConversation|releasing from conversation]].
+
Loads all the current quest givers. Each consecutive quest giver is stored in the variable "$quest_giver_i" where i is the number of the quest giver starting at 0. Also stores the number of quests in the variable "$quest_count".  
 +
 
 +
For how to use these variables, look at the barkeep's dialogue.

Revision as of 08:25, 11 January 2018

In Staxel, there are two files which are used to specify all villager dialogue in game. These files are the *.dialogue files which point to an associated .json file that was created using Yarn.


*.dialogue File

Creating a *.dialogue File

Creating this file is very simple with only two properties. The full file looks like;

{
  "code" : "mods.modname.village.character.dialogue.CecileFond",
  "dialogue" : "staxel/village/character/dialogue/CecileFond.json"
}

Both properties are self-explanatory. Make sure the dialogue property points to a file that is created by Yarn otherwise some issues can arise.


Config Options

"code"

Valid options (String): A unique string which dialogue what this object is.

Default Value: No default value is specified. Always need to provide your own.


A string containing the unique identifier of this dialogue. This is commonly only used in Dialogue Pools.


"dialogue"

Valid options (String): A string which contains the path to a Yarn .json file.

Default Value: Null or nothing specified.


A string containing the path of the item the blob will be referring to.


The Yarn *.json file

Yarn is the program which creates the dialogue files for Staxel. It utilises it's own scripting language which can make choices and also use conditional statements in order to provide the right dialogue. They also include an editor which helps visualise these files.

Look at the documentation around Yarn, particularly sections such as this. Do not Yarn is changing frequently and documentation might not line up with the implementation used in Staxel.

Additional Dialogue Functions

These are additional functions that Staxel offers to integrate the dialogue into the game. They range from functions that do decision making to functions which give and take items and money from the player.

Branching Functions

These functions cause the game to go to a different dialogue when a certain condition is met.


branchAchievementNotCompleted

Usage: <<branchAchievementNotCompleted staxel.achievement.PlantCrop PlantingWait>>

Parameter 1: Code of the Achievement you want to check. (e.g. staxel.achievement.PlantCrop)

Parameter 2: Title of the Node to move to.


When this function is hit, it will check if the selected Achievement has been completed. If it has been completed it will continue on normally. If it has not been completed, then it will move to the specified node.

Useful for checking for completed actions, such as checking if the player has placed a Pet House.


branchBuildingHasExisted

Usage: <<branchBuildingHasExisted staxel.totem.workplace.Patisserie Existed>>

Parameter 1: Code of the Totem you want to check. (e.g. staxel.totem.workplace.Patisserie)

Parameter 2: Title of the Node to move to.


When this function is hit, it will check if the specified Totem has been completed at some point (i.e Has been built). If it hasn't then continue on normally. If it has been completed, then move to the specified node.

This is useful for making sure you only talk about buildings that exist or have existed. (Note: Building does need to have been built before. Just placing totem doesn't count.)


If you require that it does exist then check #branchValidStructureExists.


branchHasUnclaimedAchievementRewards

Usage: <<branchHasUnclaimedAchievementRewards AchieveRewards>>

Parameter 1: Title of the Node to move to.

When this function is hit, it will check if the player has unclaimed rewards. If they do, then it will head to the specified node, otherwise continues on normally.


Mainly used by Farm Fan to give the player rewards. Not too useful for other players.


branchPlayerCantAffordItem

Usage: <<branchPlayerCantAffordItem item staxel.item.crafting.MugOSap 1 CantAfford>>

Parameter 1: Can be item, tilePlacer, plant, recipe or clothing. Use item for Items. Use tilePlacer for Tiles. Use plant for [[Plants|seeds. Use recipe for Recipes and use clothing for Accessories.

Parameter 2: Code of the thing you want to buy. (e.g. staxel.item.crafting.MugOSap)

Parameter 3: Number of the item you want the player to buy.

Parameter 4: Title of the Node to move to.

Parameter 5: (Optional) The multiplier to the price. (i.e. 2.00 to make it 2 times as expensive. 0.5 to make it half as expensive.)


When this function is hit, it will check if the player can afford the item. If they can then continue on normally. If they can't then move onto the specified node.


This is useful for checking if the player can actually afford the item.


branchPlayerDoesntHaveItemOfCategory

Usage: <<branchPlayerDoesntHaveItemOfCategory seed PlantingGive>>

Parameter 1: Category to look for for any item in the player's inventory.

Parameter 2: Title of the Node to move to.


When this function is hit, it will check if the player has an item with the specific category. If they do, continue on normally and if they don't, move to the specified node.


This is useful for checking if the player has an item that the NPC wants. (For example, check for seeds so that the tutorial can teach the player how to place them.)


branchPlayerDoesntHavePlayerItem

Usage: <<branchPlayerDoesntHavePlayerItem staxel.item.FarmRegistrationLetter GoodBye>>

Parameter 1: Code of the Item you want to check. (e.g. staxel.crop.tomato)

Parameter 2: Title of the Node to move to.


When this function is hit, it will check if the player has an item of a specific code. If they do, continue on normally and if they don't, move to the specified node.


This is useful for checking if the player has an item that the NPC wants. (For example, check for seeds so that the tutorial can teach the player how to place them.)


branchNoVillagerWithPersonality

Usage: <<branchNoVillagerWithPersonality staxel.village.personality.Tomboy NoTomboy>>

Parameter 1: Code of the Villager Personality to search for. (e.g staxel.village.personality.Tomboy)

Parameter 2: Title of the Node to move to.


When this function is hit, it will search to see if a villager with the specified personality exists in the world. If they do, continue on normally and if they don't, move to the specified node.


This is useful for when you want to talk about another type of villager that may or may not be in the village.


branchNoVillagerWithName

Usage: <<branchNoVillagerWithName Leif TellRumour>>

Parameter 1: Name of villager to look for.

Parameter 2: Title of the Node to move to.


When this function is hit, it will search to see if a villager with the specified name exists in the world. If they do, continue on normally and if they don't, then move to the specified node.


This is useful for when you want to talk about another specific villager that may or may not be in the village. It is probably better to use #branchNoVillagerWithPersonality as it is more specific.


branchValidStructureExists

Usage: <<branchValidStructureExists staxel.totem.AirshipLanding AirshipAvailable>>

Parameter 1: Code of the Totem you want to check. (e.g. staxel.totem.AirshipLanding)

Parameter 2: Title of the Node to move to.


When this function is hit, it will search to see if a valid totem of the type specified exists. If it does, then head to the specified node otherwise it continues on normally.


Useful for checking that a building actually exists, and is still existing, before going to it/ talking about it.

If you want to know that the building existed at some point then head to #branchValidStructureExists.


Dialogue Control Functions

These functions determine how the dialogue looks and feels to the player.


lockPlayerInConversation / releasePlayerFromConversation

Usage: <<lockPlayerInConversation>> or <<releasePlayerFromConversation>>


LockPlayerInConversation forces the player to enter into conversation mode. Conversation mode does several things;

  • Stop the player from moving.
  • Brings in the black bars
  • Focuses player focus onto the NPC

ReleasePlayerFromConversation removes conversation mode from the player. Allowing them to move off and end the conversation. A <<typewriterMode off true true>> should be placed with this command if <<typewritermode on>> was present.

This is used for all dialogue that is personal to the player. (i.e. Not merchant chatter.)


pickRandomLine

Usage:

<<pickRandomLine>>

This is line 1.

This is line 2.

<<flushRandomLine>>


Choose a single line, from a number of text only lines, randomly up either up to the end of the node or up to the command <<flushRandomLine>>. Used to select either a random section of text so that it doesn't repeat the same text too often.


pickRandomPath

Usage:

<<pickRandomPath>>

<<NodeName1>>

<<NodeName2>>

<<flushRandomPath>>


Choose a single line, from a number of node names, randomly up either up to the end of the node or up to the command <<flushRandomPath>>. Used to select a random node to go to so the same section of text isn't repeated often. Less clutter, in the one node, than #pickRandomPath when dealing with larger conversations.


resumeProgress

Usage: <<resumeProgress>>>>


Resume the last node that was saved for the current player. If there is no saved value or if saved value is the "Start" node then continue on the current node.


saveProgress

Usage: <<saveProgress>> or <<saveProgress NodeA>>

Parameter 1: The title of the node to save. (Skipping means the last node is saved.)


This saves the current node to a variable which is then stored. Useful for when a conversation needs to be completed. (e.g. It is used in the tutorial to save the last location Farm Fan was in.)


shuffleNextOptions

Usage: <<shuffleNextOptions>>


Make the next set of options be in a random order when shown to the player.


typewriterMode

Usage: <<typewriterMode on>> or <<typewriterMode off true true>>

Parameter 1: Turn on or off typewriter mode.

Parameter 2: (If Parameter 1 is off) Clear the message so it doesn't stay around. (Set to False to keep messages after this value)

Paremeter 3: (If Parameter 1 is off and Parameter 2 is True) Setting to True lets the current node immediately end without the need to click. (e.g Ending conversation immediately.)


Setting the typewriter to on makes it so text is filtered out a single character at a time instead of the entire message appearing at once. Should be turned off at the end of a conversation (i.e. <<typewriterMode off true true>>) before releasing from conversation.


Useful Functions

These are a collection of functions that will provide useful game benefits. This includes giving items, money and other functions.


adjustReputation

Usage: <<adjustReputation 20>>

Parameter 1: Amount to adjust by.


Adjust the player's reputation with this villager by the amount specified.


emote

Usage: <<emote staxel.emote.ScratchHead>>

Parameter 1: Code of the Emote you want to play. (e.g. staxel.emote.ScratchHead)


Play a specified emote and wait until it is finished.


giveItemToPlayerIfDoesntHave

Usage: <<giveItemToPlayerIfDoesntHave item staxel.item.tool.Hoe>>

Parameter 1: Can be item, tilePlacer, plant, recipe or clothing. Use item for Items. Use tilePlacer for Tiles. Use plant for [[Plants|seeds. Use recipe for Recipes and use clothing for Accessories.

Parameter 2: Code of the thing you want to check and give. (e.g. staxel.item.tool.Hoe)

Parameter 3: Number of the item you want to give the player.


Give an item to the player if they do not have the item already.


giveItemToPlayerIfCantAfford

Usage: <<giveItemToPlayerIfCantAfford plant staxel.crop.Tomato>>

Parameter 1: Can be item, tilePlacer, plant, recipe or clothing. Use item for Items. Use tilePlacer for Tiles. Use plant for [[Plants|seeds. Use recipe for Recipes and use clothing for Accessories.

Parameter 2: Code of the thing you want to check and give. (e.g. staxel.item.tool.Hoe)

Parameter 3: Number of the item you want to give the player.


Give an item to the player if they can't afford to buy that item.


givePlayerPetals

Usage: <<givePlayerPetals 42>>

Parameter 1: Amount of Petals to give.


Give the amount of petals specified to the player.


givePlayerPetalsIfInsufficient

Usage: <<givePlayerPetalsIfInsufficient 42>>

Parameter 1: Amount of Petals to check for. Amount of Petals to give.


Give the amount of petals specified to the player if the player does not have the amount or more. (If player has less than 1000 petals, give 1000 petals)


giveUnlockedAchievementRewards

Usage: <<giveUnlockedAchievementRewards>>


Give all the unclaimed items from achievements to the player.


loadItemBuyPrice

Usage: <<loadItemBuyPrice item staxel.item.crafting.MugOSap 1 $sap>>

Parameter 1: Can be item, tilePlacer, plant, recipe or clothing. Use item for Items. Use tilePlacer for Tiles. Use plant for [[Plants|seeds. Use recipe for Recipes and use clothing for Accessories.

Parameter 2: Code of the thing you want to check and give. (e.g. staxel.item.tool.Hoe)

Parameter 3: Number of the item you want to give the player.

Parameter 4: The name of the variable you want to use. Should start with $.


Calculates the cost of the specified item and places the value into the variable specified.


loadVillagerName

Usage: <<loadVillagerName Cecile $c_name>>

Parameter 1: Name of villager to search for.

Parameter 2: The name of the variable you want to use. Should start with $.

Searches for a villager with the specified name. If that villager does exist, then it places their code name into the target variable.


This is used specifically for loading the right translation for the villager's name. It is probably better to use #loadVillagerNameForPersonality as it is more specific.


loadVillagerNameForPersonality

Usage: <<loadVillagerNameForPersonality staxel.village.personality.Mayor $mayor_name>>

Parameter 1: Code of the Villager Personality to search for. (e.g staxel.village.personality.Mayor)

Parameter 2: The name of the variable you want to use. Should start with $.


Searches for a villager with the specified personality. If that villager does exist, then it places their name into the target variable.


This is used specifically for loading the right translation for the villager's name.


playerPurchaseItem

Usage: <<playerPurchaseItem item staxel.item.crafting.MugOSap>>

Parameter 1: Can be item, tilePlacer, plant, recipe or clothing. Use item for Items. Use tilePlacer for Tiles. Use plant for [[Plants|seeds. Use recipe for Recipes and use clothing for Accessories.

Parameter 2: Code of the thing you want to check and give. (e.g. staxel.item.tool.Hoe)

Parameter 3: Number of the item you want to give the player.


Purchases the item if the player can afford the item.


moveTo

Usage: <<moveTo TavernEntrance>>

Parameter 1: Waypoint Kind to find. Can be one of: Any, ChillSpot, Tutorial Spawn, NearShippingDock, NearCatalogue, Fields, Totem, Pathing, MayorsOffice, Shop, TavernEntrance, BarArea, TownSquare, ShopEntrance


Move the NPC to the nearest node of the kind specified. You cannot specify any particular node, just the closest.


leadTo

Usage: <<leadTo TavernEntrance>>

Parameter 1: Waypoint Kind to find. Can be one of: Any, ChillSpot, Tutorial Spawn, NearShippingDock, NearCatalogue, Fields, Totem, Pathing, MayorsOffice, Shop, TavernEntrance, BarArea, TownSquare, ShopEntrance


Move the NPC to the nearest node of the kind specified. Stops to wave at player if they are too far away.


removePlayerItem

Usage: <<removePlayerItem staxel.item.FarmRegistrationLetter>>

Parameter 1: Code of the Item you want to remove. (e.g. staxel.crop.tomato)


Remove the item specified if the player has it. Do nothing if there is no item.


Use this in combination with #branchPlayerDoesntHavePlayerItem to enforce that an item is needed.


Quest Functions

These functions are useful for organising quests. You will generally not have to deal with these functions unless you want to make new quests.


acceptQuest

Usage: <<acceptQuest>>


If the speaker has a quest, then activate the quest for the player. Gives the start item (i.e. Delivery Item), if needed, to the player.


branchQuestActive

Usage: <<branchQuestActive CheckCompletion>>

Parameter 1: Title of the Node to move to.


When this function is hit, it will check if the player has this person's specific quest. If the speaker has no quest or the player doesn't have the quest or the player does have the quest but it's for the wrong day, continue on normally. Otherwise go to the node.


branchQuestCompletable

Usage: <<branchQuestCompletable CompleteQuest>>

Parameter 1: Title of the Node to move to.


When this function is hit, it will check if the player has completed this person's specific quest. If the speaker has no quest or the player does have the quest but it's for the wrong day or if the quest is not complete-able then continue on normally. Otherwise go to the node.


branchQuestTarget

Usage: <<branchQuestTarget TargetDialogue>>

Parameter 1: Title of the Node to move to.


This is specifically for delivery type quests. When this function is hit, it will check if the player has a quest for the villager and if so, check to see if the the villager is the target of the quest. If the speaker has no quest for the villager or the villager is not the target then continue on normally. Otherwise go to the node.


cancelQuest

Usage: <<cancelQuest>>


If the player has a quest for the current speaker, then cancel that quest. Otherwise do nothing.


completeQuest

Usage: <<completeQuest>>


If the speaker has a quest, and it is completable then set the quest complete. Also give the quest reward.


loadVillageActiveQuestsInfo

Usage: <<loadVillageActiveQuestsInfo>>

Loads all the current quest givers. Each consecutive quest giver is stored in the variable "$quest_giver_i" where i is the number of the quest giver starting at 0. Also stores the number of quests in the variable "$quest_count".

For how to use these variables, look at the barkeep's dialogue.