Strings In Database Documentation

From Nexus Mods Wiki
Jump to: navigation, search

When some database table contains text that should be visible in the game (in any form), for example description of some item, the table itself stores only the id (string_name) of this string. The content (text) is stored separately in the table string. It is worth noting, that even this text is not the one used in the running game. The final versions of texts appearing in the game are exported from the string_localized table (with various language versions).

Exporting new strings

In order for a string to be exported to the game correctly, it has to have value in the string_localized table for language_id = 1 (PDG, which is sort of a working language) and language_id = 2 (ENG, which is the final English version).

While you work with the string table, all modifications made to it are automatically propagated to the string_localized table (by database trigger) with language_id = 0 (WHS, another working language which used to be mostly Czech during the development of the main game). This could make it a little bit easier to finalize the texts for export. If you caption strings for your mod with some unique identifying part of the name (which is good practice to prevent clashes with other mods anyway), you could then create SQL function that takes all such strings in the string_localized table with language_id = 0 and duplicate it (or replace existing) for language_id = 1 and 2.

Working with string in DB Addin

Working with strings in database is much more comfortable when using the DB Addin. Whenever you open a table that has some string property (column containing some string_name referencing a record in the string table), the addin automatically displays a column with the associated text (content of the string) next to it.

Example: On the picture is portion of the misc table (some columns are hidden for better readability), which is used to define various quest items. The column ui_name (1) is part of the player_item table (inherited table) and contains references to the string_name in table string. The column ui_name_text (2) has been added by the addin and contains matching text value from the string table.
Table misc opened in the DB Addin showing the string columns.

The addin lets you use these cells to modify the string values directly, without needing to open the string table. If you want to modify some text, you can just edit the text (3) and Post the changes. The addin will then update the value in the string table. You can also create completely new strings (useful when creating new items) by typing desired identifier to the string_name referencing cell (4). When you Post table with non-existing string_name reference, the addin will insert new row to the string table and also set its text to the matching text cell (3). Note that you can't easily alter the string_name identifier itself, it is generally just easier to create a new string, update all values that are referencing the old one, and then delete it.

 

Kingdom Come: Deliverance: Forum | Before you start | Tutorials & Instructions | Basic Mods | Tools | Documentation | Glossary | EULA