Skip to content

Return of Reckoning

Wiki

RoR Wiki

API:BuildTableFromCSV

From RoR Wiki
Revision as of 19:40, 16 October 2026 by Maintenance script (talk | contribs) (UI Lua API import (WAR 1.4.8))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

UI Lua API · Interface functions
Version: WAR 1.4.8

Reads a CSV file from the game data and stores its rows in a Lua table.

BuildTableFromCSV(csvPath, luaTableName)

Arguments

csvPath
string – Path of the CSV file in the game data, for example "data\\gamedata\\pregame_features.csv".
luaTableName
string – Path of the Lua table to fill, for example "PregameFeatureList".

Returns

Nothing.

Details

  • The first line of the file is the header. It gives the field names.
  • Every following line becomes one entry: luaTableName[id][fieldName] = value, where id is the first cell of the line read as a whole number, and each further cell is stored under the field name from the same column of the header.
  • Cell values are converted like this:
Cell Stored as
digits, optionally starting with - and with at most one . number
true / false (any case) boolean
anything else string
  • Reading stops at the first line whose first cell cannot be read.
  • Cells longer than 511 characters are cut.
  • The function needs at least two arguments and only reads the last two. Both must be strings.

Errors

  • Error in function call 'BuildTableFromCSV': Unable to open CSV File %s

Example

From interfacecore/source/characterselectwindow.lua:

BuildTableFromCSV("data\\gamedata\\pregame_features.csv", "PregameFeatureList")
...
-- Loop through each feature in the CSV and Populate the Data Structures
for _, featureData in ipairs( PregameFeatureList )
do
    local career = GameData.CareerLine[featureData.FEATURE_CAREER]
    local gender = GameData.Gender[featureData.FEATURE_GENDER]
    local featureName = GetPregameString( StringTables.Pregame[featureData.FEATURE_LABEL] )
    ...
end

PregameFeatureList = nil

See also