Module:FactionData
This module provides dynamic extraction methods to pull technical properties, asset files, localized titles, and structural city pool names for game factions stored within the wiki's Cargo database (specifically querying the Faction and Translation tables). It automatically handles localization fallbacks to English if a translation record is missing.
Basic Syntax
Standard Fields
To extract standard metadata, files, or core texts:
{{#invoke:FactionData|get|FACTION_ID|VARIABLE|LANGUAGE_CODE}}
Affiliated City Names
To query the regional city registry bound to a faction via an index number:
{{#invoke:FactionData|get_city|FACTION_ID|CITY_INDEX|LANGUAGE_CODE}}
FACTION_ID: The technical database key of the faction (e.g.,human,dungeon,necro).VARIABLE: The specific variable keyword node to display (see the index below).CITY_INDEX: The integer position slot of the city from the faction pool registry (e.g., from1to14).LANGUAGE_CODE: (Optional) The localization language code (e.g.,en,fr,pl). Defaults to English (en).
---
Technical Reference Index
📝 Localized Text (Language-Dependent)
These fields query localized entries and dynamically adapt to the requested language code.
| Variable | Description | Example Output (en) |
|---|---|---|
name |
The localized public name of the faction alignment. | Temple |
description |
The historical lore synopsis and gameplay overview background block text. | The Church of the Sun strives to forge... |
⚙️ Core Technical Properties
Standard mechanical values extracted directly from the primary Faction table rows.
| Variable | Description | Example Output |
|---|---|---|
icon |
Core faction asset emblem token identifier. Forced automatic Title Case formatting applies natively. | Fraction_Human
|
icon_faction_laws |
Religious law scroll illustration token identifier. Forced automatic Title Case formatting applies natively. | Scroll_Faction_Human
|
biome |
The native graphical map grid terrain ecosystem type assigned to the faction. | Grass
|
resource |
The primary unique rare trading material specialized by this faction. | gemstones
|
source_path |
The server file track directory location of the original repository JSON structure data dump. | DB/fractions/1_human.json
|
---
Practical Examples
Example 1: Localized Description Call
To fetch the French description of a specific faction layout block:
{{#invoke:FactionData|get|human|description|fr}}
Output: L’Église du Soleil s’efforce de forger la meilleure version de ses troupes polyvalentes...
Example 2: Compiling Faction Capital and Fort Names
You can easily list out structural localized strongholds from the pool registry using numerical indexes:
* '''Faction Capital:''' {{#invoke:FactionData|get_city|human|1|fr}}
* '''Secondary Keep:''' {{#invoke:FactionData|get_city|human|2|fr}}
* '''Holy Bastion:''' {{#invoke:FactionData|get_city|human|14|en}}
Output:
- Faction Capital: Luminastra
- Secondary Keep: L’étendue d’Arina
- Holy Bastion: Sunspire
Example 3: Parsing Graphical Asset Headers
Render faction banners dynamically on overview hubs:
[[File:Banner {{#invoke:FactionData|get|human|icon}}.png|128px]]
local p = {}
-- Fonction locale pour formater automatiquement les icônes en Title Case
local function capitalize(str)
if not str then return "" end
return str:gsub("(%a)([%w]*)", function(first, rest)
return first:upper() .. rest:lower()
end)
end
-- Fonction principale pour récupérer les données de la faction
-- Syntaxe : {{#invoke:FactionData|get|ID_FACTION|CHAMP|LANGUE}}
function p.get(frame)
local args = frame.args[1] and frame.args or frame:getParent().args
local faction_id = args[1]
local field = args[2]
local lang = args[3] or 'en'
if not faction_id or not field then
return "Erreur : ID de faction ou champ manquant."
end
-- 1. GESTION DES TEXTES TRADUITS (name, description)
if field == 'name' or field == 'description' then
local queryOpts = {
where = string.format('target_id="%s" AND language="%s" AND type="faction"', faction_id, lang)
}
local res = mw.ext.cargo.query('Translation', field, queryOpts)
if res and res[1] and res[1][field] then
return res[1][field]
else
-- Système de secours (fallback) vers l'anglais
if lang ~= 'en' then
local fallbackOpts = {
where = string.format('target_id="%s" AND language="en" AND type="faction"', faction_id)
}
local fallbackRes = mw.ext.cargo.query('Translation', field, fallbackOpts)
if fallbackRes and fallbackRes[1] and fallbackRes[1][field] then
return fallbackRes[1][field]
end
end
return ""
end
end
-- 2. GESTION DES DONNÉES DE LA TABLE PRINCIPALE "Faction"
local factionOpts = {
where = string.format('id="%s"', faction_id)
}
local factionRes = mw.ext.cargo.query('Faction', field, factionOpts)
if factionRes and factionRes[1] and factionRes[1][field] then
local value = factionRes[1][field]
-- Nettoyage automatique des icônes au besoin
if field == 'icon' or field == 'icon_faction_laws' then
return capitalize(value)
end
return value
end
return ""
end
-- Fonction pour récupérer le nom d'une ville spécifique par son index (1 à 14)
-- Syntaxe : {{#invoke:FactionData|get_city|ID_FACTION|INDEX_VILLE|LANGUE}}
function p.get_city(frame)
local args = frame.args[1] and frame.args or frame:getParent().args
local faction_id = args[1]
local city_index = args[2]
local lang = args[3] or 'en'
if not faction_id or not city_index then
return "Erreur : ID de faction ou index de ville manquant."
end
-- Reconstruction du target_id de la ville (ex: human_1)
local target_city_id = string.format("%s_%s", faction_id, city_index)
local queryOpts = {
where = string.format('target_id="%s" AND language="%s" AND type="FactionCityName"', target_city_id, lang)
}
local res = mw.ext.cargo.query('Translation', 'name', queryOpts)
if res and res[1] and res[1]['name'] then
return res[1]['name']
else
-- Fallback vers l'anglais si la traduction de la ville est absente
if lang ~= 'en' then
local fallbackOpts = {
where = string.format('target_id="%s" AND language="en" AND type="FactionCityName"', target_city_id)
}
local fallbackRes = mw.ext.cargo.query('Translation', 'name', fallbackOpts)
if fallbackRes and fallbackRes[1] and fallbackRes[1]['name'] then
return fallbackRes[1]['name']
end
end
return ""
end
end
return p


