Module:HeroList
From Heroes of Might and Magic: Olden Era Official Wiki
Description
This module generates an automated table of heroes belonging to a specific faction. It dynamically retrieves localization for hero names, classes, and specializations, and formats the starting skills and spells into a clean, sortable layout.
Usage
The module is invoked via the display function:
{{#invoke:HeroList|display|faction=...|language=...}}
Parameters
| Parameter | Description | Example |
|---|---|---|
faction |
The name of the faction (as stored in the Translation table). | faction=Necropolis
|
language |
Forces the Wiki language (if omitted, it detects the page suffix). | language=fr
|
Key Features
- Dynamic Localization: Translates headers (Name, Class, etc.) and hero-specific data (Names, Skills, Spells) based on the provided language.
- Automatic Formatting:
- Displays hero portraits and icons.
- Formats specializations with tooltips showing descriptions.
- Lists starting skills and spells as link-lists with icons.
- Sorting Support: The table uses the
sortableclass, allowing users to reorder heroes based on columns. - Data Cleanup: Automatically filters out campaign, tutorial, and internal testing heroes (e.g.,
cm_fun).
Implementation Example
To display all heroes of the "Necropolis" faction:
== Necropolis Heroes ==
{{#invoke:HeroList|display|faction=Necropolis}}
Technical Notes
- The module queries the
Herotable and joins data with theTranslationtable. - It uses
sortabletables; ensure the MediaWiki "Sortable" extension is active for full functionality. - Specialization icons are automatically inferred from the
HeroSpecializationtable and formatted to match faction naming conventions.
Examples
{{#invoke:HeroList|display|faction=Necropolis}}
Langue utilisée pour la requête : en
| ID | Nom traduit (requête avec language=en) |
|---|
{{#invoke:HeroList|display|faction=Grove|language=ja}}
Langue utilisée pour la requête : ja
| ID | Nom traduit (requête avec language=ja) |
|---|
local p = {}
function p.display(frame)
-- On récupère la langue, si vide on force 'en' pour voir si ça débloque
local lang = frame.args.language or "en"
local heroes = mw.ext.cargo.query("Hero", "id, name_sid", {
where = string.format("faction = '%s'", frame.args.faction or "dungeon"),
limit = 5
})
local html = {'<p>Langue utilisée pour la requête : <b>' .. lang .. '</b></p>'}
table.insert(html, '{| class="wikitable"')
table.insert(html, '! ID !! Nom traduit (requête avec language=' .. lang .. ')')
for _, h in ipairs(heroes) do
-- Requête explicite avec ta colonne 'language'
local trans = mw.ext.cargo.query("Translation", "name", {
where = string.format("target_id = '%s' AND language = '%s'", h.name_sid, lang),
limit = 1
})
local res = (trans and #trans > 0) and trans[1].name or "ÉCHEC (Aucune donnée pour cette langue)"
table.insert(html, "|-")
table.insert(html, "| " .. h.name_sid)
table.insert(html, "| " .. res)
end
table.insert(html, "|}")
return table.concat(html, "\n")
end
return p


