A .2da file is a plain-text file that describes a 2-dimensional array of data. In BioWare's games, .2da files serve many purposes, and are often crucial to the proper functioning of the game and tools. They describe many aspects of the rules and game engine. These files are plain text files that can be edited in any text editor (such as Windows' Notepad), but they are structured according to a set of rules that must be followed in order for the game and tools to read them correctly.
The more common .2da files included in the core game can often be found in the
source subdirectory of where Neverwinter Nights is installed. (The remaining .2da files are available for download.) Files located here are for reference only, as the "real" files are packaged inside .bif's. In order to introduce a new or changed .2da into the game, it needs to be placed in the
override directory or included in a hak pak.
The basic structure of a .2da is a table (rows and columns) of text. The first two lines in the file are header information that the game finds important, but that humans tend to ignore. The third line contains column headings, which are used to reference the data from within scripts (with the command
Get2DAString()). The remaining lines are the rows of data, numbered starting at 0 (so row 0 is the fourth line in the file). The first column of each row is supposed to be the row number, which is information that humans tend to find important, but that the game ignores. (The game counts rows as it reads the file, so it has no need for explicit row numbers.) There is no column heading for this first column. The remaining columns contain the interesting data.
When editing a .2da file, it is important to remember that the visual alignment of columns is purely for the benefit of humans. When the file is read by the game, any space character will start a new column, unless it is inside a quoted column. Numerous efforts at custom content have run awry of this when someone accidentally starts a new column by including a space in, for example, a descriptive label column. A common technique for handling spaces is to convert them to underscores (_) within columns. Another possibility is to include the entire column in double quotes ("). For example, if a label were to express that something is a dire badger, it could be included in a .2da file as either
"Badger Dire". BioWare almost exclusively uses the former technique (underscores).