mNo edit summary |
mNo edit summary |
||
Line 25: | Line 25: | ||
--TODO |
--TODO |
||
--DF_charPreview_portrait |
--DF_charPreview_portrait |
||
− | result = result .. "[[File:" .. p.getSurvivorsInitialsByIndex(i) .. "_charPreview_portrait|center|frameless|link=" .. name .. "]]|<div style=\"width:100%; margin: 0 auto; text-align:center;\">" .. name .. "</div>" |
+ | result = result .. "[[File:" .. p.getSurvivorsInitialsByIndex(i) .. "_charPreview_portrait.png|center|frameless|link=" .. name .. "]]|<div style=\"width:100%; margin: 0 auto; text-align:center;\">" .. name .. "</div>" |
result = result .. "[[File:UnknownSurvivor_charPreview_portrait.png|center|frameless|link=]]<div style=\"width:100%; margin: 0 auto; text-align:center;\">" .. p.getSurvivorsInitialsByIndex(i) .. "</div>}}" |
result = result .. "[[File:UnknownSurvivor_charPreview_portrait.png|center|frameless|link=]]<div style=\"width:100%; margin: 0 auto; text-align:center;\">" .. p.getSurvivorsInitialsByIndex(i) .. "</div>}}" |
||
Revision as of 09:43, 14 May 2020
local p = {}
local data = require("Module:Datatable")
local mathOps = require("Module:MathOps")
local utils = require("Module:Utils")
local frame = mw.getCurrentFrame()
local bar = "|" -- code for |
local nl = "\n"
function p.getCountOfSurvivors()
return utils.getCount("survivor")
end
function p.resolveSurvivorsTable()
local result = ""
local name
result = result .. "<div style=\"display: flex; flex-flow: row wrap; justify-content:start; color: #fff;\">"
local i = 1
while survivors[i] do
name = survivors[i].name
result = result .. "<div style=\"width:100%; margin:0 auto; text-align:center;\">[[" .. name .. "]]</div>"
--TODO
--DF_charPreview_portrait
result = result .. "[[File:" .. p.getSurvivorsInitialsByIndex(i) .. "_charPreview_portrait.png|center|frameless|link=" .. name .. "]]|<div style=\"width:100%; margin: 0 auto; text-align:center;\">" .. name .. "</div>"
result = result .. "[[File:UnknownSurvivor_charPreview_portrait.png|center|frameless|link=]]<div style=\"width:100%; margin: 0 auto; text-align:center;\">" .. p.getSurvivorsInitialsByIndex(i) .. "</div>}}"
i = i + 1
end
result = result .. "</div>"
return result
end
function p.getSurvivorsInitialsByIndex(i)
if type(i) == "string" then
i = getSurvivorIndexByName(i)
elseif type(i) == "table" then
i = getSurvivorIndexByName(i.args[1])
end
local firstLetter, lastLetter
firstLetter, lastLetter = survivors[i].name:match("^(%S).+ (%S).-$")
return firstLetter .. lastLetter
end
function getSurvivorIndexByName(name)
local i = 1
while survivors[i] do
if survivors[i].name == name then
return i
end
i = i + 1
end
return 0
end
return p