Module:Database

function data return mw.loadData("Module:GameData") end

function loc return mw.loadData("Module:GameLoc") end

function findByIname(list, iname) for i, item in pairs(list) do   if iname == item["iname"] then return item end end return nil end

function findLoc(list, prefix, iname, suffix) local key = table.concat({prefix,"_",iname,"_",suffix,"\t"}) for i, line in pairs(list) do   local t = line:find("\t") if line:sub(1,t) == key then return line:sub(t + 1) end end return nil end

local p = {}

function p.unit_icon(frame) local iname = frame.args[1] return table.concat({   " [[File:portrait_",    findByIname(data["MasterParam"]["Unit"], iname)["img"],    ".png|128px|",    frame:expandTemplate{ title = ":Data:Unit/Name", args = {iname} },    "|link=",    frame:expandTemplate{ title = ":Data:Unit/PageName", args = {iname} },    "]]  ",    frame:expandTemplate{ title = "Unit/Name", args = {iname} },    "  "  }) end

return p