Dialogue

From wiki
Revision as of 05:54, 15 June 2017 by DeamonHunter (Talk | contribs) (Added 8 Functions. Still more to come.)

Jump to: navigation, search

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 Functions

There are additional functions that Staxel offers to integrate the dialogue into the game.

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 if failed


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 villager that may or may not be in the village.


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)


moveTo

Usage: <<moveTo TavernEntrance>>

Parameter 1: Waypoint Kind to find. Can be 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 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.


shuffleNextOptions

Usage: <<shuffleNextOptions>>


Make the next set of options be in a random order.