TalkTables

From NWN1 Custom Content Guide

Jump to: navigation, search

Contents

[edit] General

Talk tables, .TLK files, contain text resources for the game.

Certain entries in 2DAs demand references to these files via StrRefs instead of literal text.

Until 1.59, the only .TLK file that the game reads is dialog.tlk (and dialogF.tlk if needed by the language, see below). Editing it is not a good solution. With more recent versions, you can create a talk table specific to a module, and use the text it contains.

When the game or toolset needs to display a language-dependent string to the user, it gets the string from the talk table by specifying a String Reference (abbreviated StringRef or StrRef), an integer ID that uniquely identifies which string to fetch from the table. The ID is the same across all language versions of the game, but the associated text itself is in the user's own language. The text contained in the talk table varies by language.

Imagine you want to use the following text in game: "Hello", "World", "You are exhausted".

Well you could create a TLK file summed up by the following list:

0 "Bad StrRef"
1 "Hello"
2 "World"
3 "You are exhausted"
Note the first entry (index 0) of any TLK denotes an invalid reference. This probably is hard coded in the way NWN access this data, so you shouldn't use it for anything else. You might as well put "Bad StrRef" there to make things explicit.

However German, Spanish, Italian, Polish and French speaking people (sorry if I forgot anyone, especially Korean or Japanese) will have a problem (well not necessarily all of them with the example I gave). The grammars for these languages create important variation depending on the sex of the speaker/listener/person spoke of. And you don't know before hand the sex of the PC the player will create. For these languages the talk tables actually go by pairs (dialog.tlk and dialogF.tlk are the one Bioware uses). Depending on the sex of the PC the StrRef asked for will be retrieved from one or the other file. In French the equivalent of the TLK file described above would be:

"male" file "female" file
0 "Bad StrRef"
1 "Bonjour"
2 "Monde"
3 "Vous êtes épuisé"
0 "Bad StrRef"
1 "Bonjour"
2 "Monde"
3 "Vous êtes épuisée"

[edit] Custom TLKs

The custom talktable feature was added because it was one of the last things blocking the community from adding new feats, spells, races, etc into NWN using hakpaks.

If you add a new spell to the game, you need to modify spells.2da to add it - and inside spells.2da you need to define StrRefs (string reference) that point to strings in dialog.tlk for "name", "description", etc. These strings are displayed on the players GUI and are directly fetched from dialog.tlk. Basically if I enter StrRef 333, it will fetch string number 333 from dialog.tlk.

However, dialog.tlk can not be put into hakpaks and it is a global resource, meaning you can't just add strings to it and distribute it to your players, as your changes will affect all games that are played and will break compatibility with the auto updater.

To allow the community to define their own strings, Bioware came up with a scheme that allows module builders to add their own, custom talktable to a module. This talktable can NOT redefine existing strings, it can only add new strings to the game. Thus, you can't simply take dialog.tlk and copy it, you need to create a new, empty talktable and add the strings you want to add to the game there. There is NO way of overwriting existing strings - If you want to change the name of a spell, you would instead change the StrRef in the Name column in spells.2da to point to your new string in your own talktable.

So, for an example of the Champion of Torm:

You create an empty talktable (plenty of tools for that on the Vault) and add three new strings

0 "Bad StrRef"
1 "Divine Champion"
2 "Description for Divine Champion"

You need to modify the name and probably description column in classes.2da to point to your new, custom strref. In order to address entries in the custom talktable, you need to add 16777216 to the index number the string has in your custom talktable.

The classes.2da entry would look like this:

... name description ...
...
... 16777217 16777218 ...

Then in the toolset, under the Module Properties in the Custom Content page, you associate your custom .TLK with the mod. Unlike HakPaks you can only have one custom .TLK per module (which makes sense as the info is appended in order). In order for it to be associated with a module, the custom .TLK must be in the subdirectory \tlk of your Neverwinter Nights directory. If this subdirectory doesn't exist, you can create it.

So to summarize, think of the TLK files and ranges like this:

In file Starts from to You use to
dialog.tlk 0 16777215 0 16777215
custom.tlk 0  ? 16777216 16777216+?

The game reads the .TLK in this matter.

If the index is below 0x1000000 dialogue.tlk

If the index is above 0x1000000 mask off the "1" and read the custom.tlk, if entry doesn't exist read dialog.tlk. (still with "1" masked of) so you can get odd strings if you have wrong references too a custom.tlk somewhere.

If you want to change hardcoded "strings" and add them in your hakpak, don't use dialog.tlk. Instead copy and change the hardcoded GUI files string reference and add it too the hakpak (this is mostly used for changes of the character creator).

[edit] Editing a TLK

As .TLK files are binary files, not simple text files, so you will need a TLK editor to create or modify it.

A quick search from NWVault:

[edit] Padding a TLK

....using NWN TLK Editor...

  1. Open the .TLK you want to pad.
  2. Go to 'New.' Note that this adds a new entry into the .TLK] rather than making a completely new file.
  3. Type in the entry number for the line you want to pad up to. For example, if I want to pad a .TLK up to 90,000 I simply type '90000' in the pop-up-box title 'Enter entry number' (this is the first box that pops up when you click 'New').
  4. Press OK. The next box should give options to type in the misc title and entry field - if you want to edit this area, feel free, but it is not essential for the purposes of padding the .tlk. For now, just click OK.

    An explanation of how this works: because we have asked the program to make an entry for which there are no intermediary entries, the program must put something there, else it will not automatically know that there is something there...in the same way that the number column in a .2DA is for our benefit only; when checking the .2DA (or .TLK) the system only checks in consecutive order. Thus in order for there to BE an entry at 90,000, the program has to make the entries from the last entry in the custom .TLK up to and including the entry it wishes to make. Don't worry if you don't understand how this works...follow the steps and it'll work!

You're done. Easy, no? Should you wish to carry on editing, two things to remember about this editor

  1. To edit an entry, double click on the ID number.
  2. Avoid the cancel button like the plague. The cancel is quite buggy, and will either copy a previous entry if the entry you are using is blank, or simply make a new blank entry if you want to cancel the current entry. In short, delete an text you put in if you want to remove an entry, and press OK.

Main Page | TalkTables

Personal tools