Dialogue
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.
Contents
- 1 *.dialogue File
- 2 The Yarn *.json file
- 2.1 Additional Functions
- 2.1.1 acceptQuest
- 2.1.2 branchAchievementNotCompleted
- 2.1.3 branchBuildingHasExisted
- 2.1.4 branchPlayerCantAffordItem
- 2.1.5 branchPlayerDoesntHaveItemOfCategory
- 2.1.6 branchPlayerDoesntHavePlayerItem
- 2.1.7 branchQuestActive
- 2.1.8 branchQuestCompletable
- 2.1.9 branchNoVillagerWithPersonality
- 2.1.10 branchNoVillagerWithName
- 2.1.11 cancelQuest
- 2.1.12 completeQuest
- 2.1.13 emote
- 2.1.14 giveItemToPlayerIfDoesntHave
- 2.1.15 giveItemToPlayerIfCantAfford
- 2.1.16 givePlayerPetals
- 2.1.17 givePlayerPetalsIfInsufficient
- 2.1.18 lockPlayerInConversation / releasePlayerFromConversation
- 2.1.19 pickRandomLine
- 2.1.20 pickRandomPath
- 2.1.21 moveTo
- 2.1.22 leadTo
- 2.1.23 removePlayerItem
- 2.1.24 resumeProgress
- 2.1.25 saveProgress
- 2.1.26 shuffleNextOptions
- 2.1.27 typewriterMode
- 2.1 Additional Functions
*.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 Functions
There are additional functions that Staxel offers to integrate the dialogue into the game.
acceptQuest
Usage: <<acceptQuest>>
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.
branchAchievementNotCompleted
Usage: <<branchAchievementNotCompleted staxel.achievement.PlantCrop PlantingWait>>
Parameter 1: Achievement code to look for.
Parameter 2: Title of the Node to move to.
When this function is hit, will check if the selected achievement has been completed. If it is not completed, continue on normally. If it is, then move to the specified node. Useful for checking for completed actions, such as the uses in the tutorial.
branchBuildingHasExisted
Usage: <<branchBuildingHasExisted staxel.totem.workplace.Patisserie Existed>>
Parameter 1: Totem code to search for.
Parameter 2: Title of the Node to move to.
When this function is hit, will check if the building with the specified totem has existed at some point. If it didn't, continue on normally. If they did, then move to the specified node. This is useful for making sure you only talk about existing buildings. (Note: Building does need to have been built before. Just placing totem doesn't count.)
branchPlayerCantAffordItem
Usage: <<branchPlayerCantAffordItem item staxel.item.crafting.MugOSap 1 CantAfford>>
Parameter 1: Can be item, tilePlacer or plant
. 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)
Parameter 3: Title of the Node to move to.
When this function is hit, will check if the player can afford the item. If they do, continue on normally. If they don't, then move to the specified node. This is useful for only giving an option if the player can afford it.
branchPlayerDoesntHaveItemOfCategory
Usage: <<branchPlayerDoesntHaveItemOfCategory seed PlantingGive>>
Parameter 1: Category to look for.
Parameter 2: Title of the Node to move to.
When this function is hit, will check if the player can afford has an item with a specific category. If they do, continue on normally. If they don't, then move to the specified node.
branchPlayerDoesntHavePlayerItem
Usage: <<branchPlayerDoesntHavePlayerItem staxel.item.FarmRegistrationLetter GoodBye>>
Parameter 1: Item code. (e.g. staxel.crop.tomato)
Parameter 2: Title of the Node to move to.
When this function is hit, will check if the player can afford has an item of a specific code. If they do, continue on normally. If they don't, then move to the specified node.
branchQuestActive
Usage: <<branchQuestActive CheckCompletion>>
Parameter 1: Title of the Node to move to.
When this function is hit, 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.
branchQuestCompletable
Usage: <<branchQuestCompletable CompleteQuest>>
Parameter 1: Title of the Node to move to.
When this function is hit, 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 complete-able then continue on normally. Otherwise go to the node.
branchNoVillagerWithPersonality
Usage: <<branchNoVillagerWithPersonality staxel.village.personality.Tomboy NoTomboy>>
Parameter 1: Code of the personality to search for. (e.g staxel.village.personality)
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. If they don't, then 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 person 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. 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.
cancelQuest
Usage: <<completeQuest>>
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.
emote
Usage: <<emote staxel.emote.ScratchHead>>
Parameter 1: Emote code to play.
Play a specified emote and wait until it is finished.
giveItemToPlayerIfDoesntHave
Usage: <<giveItemToPlayerIfDoesntHave item staxel.item.tool.Hoe>>
Parameter 1: Can be item, tilePlacer or plant
. 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)
Give an item to the player if they do not have the item already. The first parameter is the item type while the second is the code of the item to spawn.
giveItemToPlayerIfCantAfford
Usage: <<giveItemToPlayerIfDoesntHave item staxel.item.tool.Hoe>>
Parameter 1: Can be item, tilePlacer or plant
. Use item for items. Use tilePlacer for TileObjects or Tiles. Use plant for Seeds.
Parameter 2: Item/Tile/Seed code.
Give an item to the player if they can't afford to buy that item. The first parameter is the item type while the second is the code of the item to spawn.
givePlayerPetals
Usage: <<givePlayerPetalsIfInsufficient 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)
lockPlayerInConversation / releasePlayerFromConversation
Usage: <<lockPlayerInConversation>>
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.
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 than #pickRandomPath when dealing with larger conversations.
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.
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 if too far from player.
removePlayerItem
Usage: <<removePlayerItem staxel.item.FarmRegistrationLetter>>
Parameter 1: Item code to remove.
Remove the item specified if the player has it. Do nothing if there is no item.
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.
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.