Module:SubSkillsTable
From Heroes of Might and Magic: Olden Era Official Wiki
Documentation for this module may be created at Module:SubSkillsTable/doc
local p = {}
-- Fonction utilitaire pour récupérer la traduction
local function getTrans(target_id, type, lang, field)
field = field or "name"
local res = mw.ext.cargo.query("Translation", field, {
where = string.format("target_id = '%s' AND type = '%s' AND language = '%s'", target_id, type, lang),
limit = 1
})
return (res and #res > 0) and res[1][field] or ""
end
function p.display(frame)
local skill_id = frame.args["id"] -- ex: skill_assault
local lang = frame.args.language or "en"
-- 1. Récupération des niveaux (1, 2, 3)
local levels = mw.ext.cargo.query("SkillLevelDef", "level, icon, offered_sub_skills", {
where = string.format("skill_id = '%s'", skill_id),
orderBy = "level ASC"
})
local html = {'{| class="wikitable" style="width:100%"'}
-- En-têtes (à adapter selon ton besoin)
table.insert(html, '! colspan=2 | Name !! colspan=6 | Description')
for _, lvl in ipairs(levels) do
local trans_name = getTrans(skill_id, "skill_level", lang, "name")
local trans_desc = getTrans(skill_id, "skill_level", lang, "description")
-- Construction de la ligne pour chaque niveau
table.insert(html, '|- style="vertical-align:top;"')
table.insert(html, '| style="text-align:right;" | [[File:' .. lvl.icon .. '.png|70px]]')
table.insert(html, '| \'\'\'' .. trans_name .. '\'\'\' <br /><span style="color: #DDD;">' .. trans_desc .. '</span>')
-- Ici, tu peux ajouter une logique pour afficher les sub_skills récupérés dans lvl.offered_sub_skills
-- ...
end
table.insert(html, "|}")
return table.concat(html, "\n")
end
return p


