LuaDBC is a parser for WoW's DB2 files implemented in Lua.
Installation
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.
API
- 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.
- i
- Signed integer, returns a number.
- u
- Unsigned integer, returns a number.
- f
- 32-bit IEEE 754 float, returns a number.
- s
- Null-terminated string, returns a string (without the terminator).
- L
- 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].
- F
- Foreign key associated with the record, returns a number. This field can be used at any position in a signature when a foreign key mapping is present in the data, and does not advance the current field pointer.
- I
- Signed integer, returns a number. This type disables the heuristic narrowing for certain packing types.
- U
- Unsigned integer, returns a number. This type disables the heuristic narrowing for certain packing types.
- ?
- Automatically guess column type.
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 rowSignature 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 fields present in the file, with the exception of the foreign key (if present).