Module:Survivors

local p = {} local data = require("Module:Datatable") local mathOps = require("Module:MathOps") local utils = require("Module:Utils") local frame = mw.getCurrentFrame local bar = "&#124;" -- code for | local nl = "\n"

function p.getCountOfSurvivors return utils.getCount("survivor") end

function getSurvivorIndexById(id) for i, s in ipairs(survivors) do		if s.id == id then return i end end return 0 end

function getSurvivorIndexByName(name) --not used local i = 1 while survivors[i] do		if survivors[i].name == name then return i		end i = i + 1 end return 0 end

function p.resolveSurvivorsTable local result = "" local name local fileName

result = result .. "" for i, survivor in ipairs(survivors) do		fileName = resolveSurvivorsPortraitFileNameById(survivor.id) result = result .. "" .. survivor.name .. "" result = result .. " "

end result = result .. " "

return result end

function p.resolveSurvivorsTableMainPage local result = "" local name local fileName

result = result .. "" result = result .. "The Survivors " result = result .. "" for i, survivor in ipairs(survivors) do		name = survivor.shortName or survivor.name fileName = resolveSurvivorsPortraitFileNameById(survivor.id) result = result .. "" result = result .. " " result = result .. "" .. name .. "    " end result = result .. " "	result = result .. " "

return result end function resolveSurvivorsPortraitFileNameById(id) local fileConst = "_charPreview_portrait" local fileName fileName = getFileNameFromTableById(id) if not utils.isValidFileName(fileName) then --S{ID}_charPreview_portrait fileName = "S" .. string.format("%02d", id) .. fileConst end if not utils.isValidFileName(fileName) then --File not Found fileName = "UnknownSurvivor" .. fileConst end mw.log(fileName) return fileName end

function getFileNameFromTableById(id) mw.log(id) for j, sImage in ipairs(survivorImages) do		if sImage.id == id then return sImage.preview end end return "" end

function getDlcById(id) for _, dlc in ipairs(dlcs) do		if dlc.id == id then return dlc end end end

return p