module documentation
Read and write TLK (Talk Table) files (for translation and base game string references).
All strings are transparently converted to and from the NWN encoding.
Class |
|
A single entry in a TLK file including the text, sound resref, and sound length. Only used when reading TLK files with sound data. |
Function | read |
Reads a TLK file fully into memory and returns a list of entries. |
Function | write |
Writes a Tlk object to a binary file. |
def read(file:
BinaryIO
, include_sound_data=False, max_entries=524287) -> tuple[ list, Language]
:
(source)
¶
Reads a TLK file fully into memory and returns a list of entries.
Parameters | |
file:BinaryIO | A binary file object containing the TLK file. |
include | If True, entries are returned as TlkEntry objects. Otherwise, the resulting dict will contain only the text. |
max | The maximum number of entries to read from the TLK file. This is a sanity check to avoid allocating excess memory when reading untrusted or corrupted data. |
Returns | |
tuple[ |
|
Raises | |
ValueError | If the file does not contain valid TLK data. |
Writes a Tlk object to a binary file.
Parameters | |
file:BinaryIO | A binary file object to write the TLK data to. |
entries:list | A list containing the entries to write, in order. Entries can be either strings or TlkEntry objects. |
language:Language | The language of the TLK file to write. |
Raises | |
ValueError | If the TLK object contains invalid data. |