Module:Table Animals
From Eco - English Wiki
Documentation for this module may be created at Module:Table Animals/doc
local p = {}
local Utils = require("Module:Utils")
local AnimalUtils = require("Module:UtilsAnimalLists")
local HTMLUtils = require("Module:UtilsHTML")
local function addFootnotes(t)
-- Sadly I could not find a way to add HTML to the table header generated with the Lua code below.
-- <a id=\"cite_ref-1\" class=\"reference\" href=\"#cite_note-1\">[1]</a>
-- <a id=\"cite_ref-2\" class=\"reference\" href=\"#cite_note-2\">[2]</a>
table.insert(t, "<strong>Footnotes</strong>")
table.insert(t, "<div class=\"mw-references-wrap\">")
table.insert(t, "<ol class=\"references\">")
table.insert(t, "<li id=\"cite_note-1\"><span class=\"mw-cite-backlink\"><a href=\"#cite_ref-1\" aria-label=\"Jump up\" title=\"Jump up\">↑</a></span> <span class=\"reference-text\">Calories consumed by predator animals who eat this animal. Not applicable to players, see the <strong>Harvest Item</strong> column for details on the player consumable food items.</span></li>")
table.insert(t, "<li id=\"cite_note-2\"><span class=\"mw-cite-backlink\"><a href=\"#cite_ref-2\" aria-label=\"Jump up\" title=\"Jump up\">↑</a></span> <span class=\"reference-text\">The minimum and maximum delay between attacks. Lower values equal faster attacks.</span></li>")
table.insert(t, "</ol></div>")
end
function p.main()
-- Import the data.
local animals = require("Module:AnimalData").animals
-- Sort animals by their name so the generated table will be pre-sorted on page load.
local sortedNames = Utils.getSortedKeys(animals)
-- Table to insert data into.
local tbl = { "<table class=\"wikitable sortable\">" }
-- Create the table header.
AnimalUtils.insertAnimalListHeader(tbl)
-- Create the table rows.
for _, animalName in ipairs(sortedNames) do
AnimalUtils.insertAnimalListDataRow(tbl, animalName, animals[animalName])
end
table.insert(tbl, "</table>")
return table.concat(tbl," \n")
end
return p