Template:LuaCodeToAccessCSVDataTemplates

From Against the Storm Official Wiki
Revision as of 04:04, 1 November 2023 by Aeredor (talk | contribs) (Created for some reusable documentation for data templates)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This is a little reusable documentation snippet for data templates.

Explanation

You can use this wiki's data templates to retrieve the game data for use in any Lua module on this wiki. A utility module, CsvUtils processes the document for you, giving you just the CSV data, if you need to parse it yourself. Or, the utility module can split it for you into a Lua table.

To do this, you add these three lines in your Lua code:

  1. local CsvUtils = require('Module:CsvUtils')
  2. local rawCSV = CsvUtils.extractCSV("Template:Data_Template_csv")
  3. local luaTable, headerLookup = CsvUtils.luaTableFromCSV(rawCSV)