Difference between revisions of "Modding:Dialogue"

From Stardew Valley Wiki
Jump to navigation Jump to search
(Created page with "← Index This page explains how the game stores and obtains dialogue. This is an advanced guide for mod developers ==Source== The various dialogue options...")
 
(standardise, reorganise, copyedit)
Line 1: Line 1:
 
← [[Modding:Index|Index]]
 
← [[Modding:Index|Index]]
  
This page explains how the game stores and obtains dialogue. This is an advanced guide for mod developers
+
This page explains how the game stores dialogue text, its format, and how the game parses it. This is an advanced guide for mod developers.
  
==Source==
+
==Data==
The various dialogue options are located in the following files:
+
The dialogue text is stored in three sets of files.
* <tt>Data\Strings\StringsFromCSFiles*.xnb</tt> : A common string pool for the game, including NPC dialogue
 
* <tt>Data\Events\*.xnb</tt> : Event Specific Information.
 
* <tt>Characters\Dialogue\*.xnb</tt> :Character specific dialog
 
  
For more information on Events, click on [[Modding:Event data|Event data]]. This page will explain the format of the String Pool and Character Specific Strings, and how the game parses them.
+
===Character-specific dialogue===
 
+
<tt>Characters\Dialogue\*.xnb</tt> contains most of the dialogue for each character (one file per character). The format in this file is:
==The String Pool==
 
The Common String Pool has every bit of dialogue in the game that all Characters share. This is usually the last resort, if the game couldn't find character specific or event specific dialogue. the format of the strings located in this file are
 
  
 
<source lang="yaml">
 
<source lang="yaml">
<file most likely to use it>.<integerid>: "String" #!String
+
"<preface>[heart level]_[date]_[year][suffix]": "String"
 
</source>
 
</source>
  
Take note of the integerid. This is what the game uses in some cases to find more specific dialogue (eg: marriage dialogue).
+
...where:
 +
* {{t|preface}} is an arbitrary key which identifies what it's for (like _Introduction_, _Event_, _Season_, etc).
 +
* {{o|heart level}} is the ''minimum'' heart level the player must have reached with the NPC for this dialogue to appear.
 +
* {{o|date}} is the numeric day of the month (like _28_), or the three-character weekday (like _Mon_).
 +
* {{o|year}} is _1_ for year one, or _2_ for any year after that.
 +
* {{o|suffix}} is any string further identifying the dialogue (like <tt>_inlaw_Abigail</tt> for Pierre and Caroline, for dialogue that only appears when you're married to Abigail).
 +
 
 +
If multiple dialogues are eligible, the game prioritises by the following:
 +
# marriage status;
 +
# preface;
 +
# suffix;
 +
# in-law status;
 +
# day of month;
 +
# year;
 +
# heart level;
 +
# day of week.
 +
 
 +
===Strings from CS files===
 +
<tt>Data\Strings\StringsFromCSFiles.xnb</tt> contains many translation strings, including NPC dialogue defined in the code. That includes every bit of dialogue that's shared between multiple characters, and dialogue for some hardcoded events like marriage. The format in this file is:
  
==Character-Specific Dialogue==
 
Every Character has a .xnb file for their specific dialogue located in the Characters\Dialogue\ folder. The format for these strings are
 
 
<source lang="yaml">
 
<source lang="yaml">
<Preface>[Heart Level]_[Day Of Month/Week]_[Year Number][suffix] : "String" #!String
+
"<key>": "dialogue string"
 
</source>
 
</source>
  
Where:
+
The key is generated based on the file that contained it before translations were added (in the form {{t|file name}}.{{t|int id}}), but doesn't have any particular meaning now.
* Preface is any string identifying what it is for (Introduction, Event, Season, arbitrary things, etc.).
+
 
* Heart Level is the ''minimum'' heartlevel the npc needs to be in order for this dialogue to fire.
+
===Event files===
* Day Of Month/Week is the number day of the month or the 3-character day of the week
+
<tt>Data\Events\*.xnb</tt> contains event scripts, including any dialogue in the event (see [[Modding:Event data]]).
* Year Number is either 1 (year one) or 2 (years 2 and beyond), and
+
 
* Suffix is any string further identifying the dialogue (e.g. _inlaw_Abigail for Pierre and Caroline, identifying that this dialogue will fire if you are married to Abigail).
+
==Algorithm==
 +
The game finds as follows:
  
==Parsing==
+
# Event dialogue is read from the appropriate event commands (see [[Modding:Event data]]).
The game parses for dialogue as follows:
+
# Location-specific dialogue is read from <tt>StringsFromCSFiles {{t|location}}.cs</tt>.
 +
# Else character dialogue is read from the character-specific files.
 +
# If no dialogues were found, the game resorts to hardcoded dialogue from the <tt>StringsFromCSFiles</tt> files (specifically keys prefixed with <tt>NPC.cs</tt> NPC.cs).
  
* If it's an Event, it parses for event dialogue (Data\Events or StringsFromCSFiles Event.cs group)
+
[[Category:Modding]]
* Then it parses for location-specific dialogue (StringsFromCSFiles [location].cs group)
 
* Then it parses for Character-specific dialogue, prioritizing as follows:
 
** Marriage Status
 
** Preface value
 
** Suffix value
 
** In-law status
 
** Day of Month
 
** Year
 
** Heart Level
 
** Day of Week
 
* Then, if it can't find any after that, it resorts to the NPC.cs group in StringsFromCSFiles
 

Revision as of 15:34, 4 May 2017

Index

This page explains how the game stores dialogue text, its format, and how the game parses it. This is an advanced guide for mod developers.

Data

The dialogue text is stored in three sets of files.

Character-specific dialogue

Characters\Dialogue\*.xnb contains most of the dialogue for each character (one file per character). The format in this file is:

"<preface>[heart level]_[date]_[year][suffix]": "String"

...where:

  • <preface> is an arbitrary key which identifies what it's for (like _Introduction_, _Event_, _Season_, etc).
  • [heart level] is the minimum heart level the player must have reached with the NPC for this dialogue to appear.
  • [date] is the numeric day of the month (like _28_), or the three-character weekday (like _Mon_).
  • [year] is _1_ for year one, or _2_ for any year after that.
  • [suffix] is any string further identifying the dialogue (like _inlaw_Abigail for Pierre and Caroline, for dialogue that only appears when you're married to Abigail).

If multiple dialogues are eligible, the game prioritises by the following:

  1. marriage status;
  2. preface;
  3. suffix;
  4. in-law status;
  5. day of month;
  6. year;
  7. heart level;
  8. day of week.

Strings from CS files

Data\Strings\StringsFromCSFiles.xnb contains many translation strings, including NPC dialogue defined in the code. That includes every bit of dialogue that's shared between multiple characters, and dialogue for some hardcoded events like marriage. The format in this file is:

"<key>": "dialogue string"

The key is generated based on the file that contained it before translations were added (in the form <file name>.<int id>), but doesn't have any particular meaning now.

Event files

Data\Events\*.xnb contains event scripts, including any dialogue in the event (see Modding:Event data).

Algorithm

The game finds as follows:

  1. Event dialogue is read from the appropriate event commands (see Modding:Event data).
  2. Location-specific dialogue is read from StringsFromCSFiles <location>.cs.
  3. Else character dialogue is read from the character-specific files.
  4. If no dialogues were found, the game resorts to hardcoded dialogue from the StringsFromCSFiles files (specifically keys prefixed with NPC.cs NPC.cs).