SetTlkOverride(int, string)

From NWN Lexicon
Jump to: navigation, search
Nwnee logo.jpg Note: This article documents Neverwinter Nights: Enhanced Edition new content or changes/updates/fixes to 1.69 functions. These are all listed under the category and patches pages.

Overrides a given string reference so something else is shown.

void SetTlkOverride(
    int nStrRef,
    string sValue=""


String reference to replace
String to use, if blank it resets it to default (default: "")


Overrides a given strref to always return sValue instead of what is in the TLK file.

Setting sValue to "" will delete the override

You can use GetStringByStrRef to get what is currently reported by that nStrRef ID. It returns the overriden string if it has already been altered.


This is amazing for replacing hardcoded TLK lines; in game feedback, formatting of messages if you've altered rules. You could even replace specific messages in specific circumstances - see example. If the game requests a <CUSTOM0> or similar in the original string this may include additional formatting (eg colouring for EffectDamage messages).

Note that this does increase network bandwidth; the entire string is sent instead of a single number to look up in the local TLK files. Thus don't use this to generate an entire TLK! Only use it to replace things that are entirely hardcoded or that have to be changed dynamically for some reason.

Character generation also fires after OnModuleLoad in singleplayer so you can change TLK strings related to the otherwise hardcoded parts (eg; mentions of "Realms" in the gender description, when your world is "The land of Dragons!" or somesuch). This is much safer than altering GUI files.

This won't work for chargen in multiplayer apparently since the "these are all the TLK overrides the server has set so far" message comes after chargen. There is some tweaks available in NWNX if you run your server with it to enable chargen tlk lines to take effect.

A sample of lines you might want to override are available here and what TLK files are here.

Since a blank string will delete the override, use a space or a blank string in color codes to blank it entirely - however the game still uses a new line character so a blank line will appear in the chat log.

// Space 
string sSpace = " ";
// Blank character - but has colour code values so is valid for override
string sBlank = "<c123></c>";

Some events directly precede the feedback message - such as OnFailToOpen in the example below - but this might not always be the case. If you only want some temporary feedback changes like this see the example for a single door that feeds back a better message than "This door is locked.".


This function was added in 1.83.8193.21 of NWN:EE.


// Sample OnFailToOpen we replace the message just for this door by resetting it afterwards
void main()
    SetTlkOverride(8296, "This is locked and has no keyhole. Maybe a mechanism nearby will open it.");
    // Reset to default for all other doors. Must be longer than 0.0 (so the engine can send that string before we reset it) so we use 0.1.
    DelayCommand(0.1, SetTlkOverride(8296));
// The OnModuleLoad loads before character generation so you can replace some strings to be more relevant for your world
void main()
    // This is the same except "Realms" is replaced by "Land of Dragons"
    SetTlkOverride(199, "Males of the Land of Dragons can aspire to any field of activity, from scholarly pursuits to the arts of war.");
    SetTlkOverride(200, "Females of the Land of Dragons can aspire to any field of activity, from scholarly pursuits to the arts of war.");

See Also