LuaDBC is a parser for WoW's DB2 files implemented in Lua.


The dbc/ directory should go somewhere matched by Lua's package.path. This might be the current working directory, /usr/local/share/lua/5.1/, or a lua subdirectory in the directory containing your Lua executable.


dbc = require("dbc")
Loads the DBC/DB2-parsing module.
header = dbc.header("data")
Returns a table of properties derived from the DBC header of data.
iterator, data = dbc.rows("data", "rowSignature"[, loose])
Returns an iterator over the rows in data, returning the row index (or row ID if specified by the file), and the fields specified in rowSignature, where each character represents a field type:
Skip field, returning no value.
Signed integer, returns a number.
Unsigned integer, returns a number.
32-bit IEEE 754 float, returns a number.
Null-terminated string, returns a string (without the terminator).
64-bit unsigned integer, returns a table t = {lo, hi, m=2^32}, such that the integer's value is t[1] + t.m * t[2].
Foreign key associated with the record, returns a number. This field can be used at any position in a signature if the DBC file contains a foreign key mapping, and does not advance the current field pointer.
Automatically guess column type.
Each field type character may be preceded by an integer specifying the number of repetitions of that field type (thus u3fs and ufffs are equivalent), or * to repeat the field type until the end of row.
Curly brackets may be used to place parts of the signature inside a table: the iterator for u{3f}s returns the row index/ID, followed by a number, an array with three numbers, and a string.
If a DBC signature begins with a curly bracket, the resulting table is returned as the iterator's first return value. The row index/ID is assigned to the table's [0] key.
Unless loose is truthy, rowSignature must describe all the fields present in the file.