Module:SpellData
This module allows for the dynamic extraction of variables, asset icons, costs, and technical properties for battle/map spells stored within the wiki's Cargo database (specifically from the Spell and Translation tables). It automatically handles localized fallback to English if a translation in the requested language is missing.
Basic Syntax
To fetch a data field, use the following syntax:
{{#invoke:SpellData|get|SPELL_ID|VARIABLE|LANGUAGE_CODE}}
SPELL_ID: The technical identifier of the spell (e.g.,day_16_magic_arinas_chosen).VARIABLE: The keyword for the specific data field you want to display (see the index below).LANGUAGE_CODE: (Optional) The localization code (e.g.,en,fr,pt_br). Defaults to English (en).
---
Technical Reference Index
📝 Text & Translations (Language-Dependent)
These fields query the Translation table. They dynamically adapt to the requested language code.
| Variable | Description | Example Output (en) |
|---|---|---|
name |
The localized display name of the spell. | Arina's Chosen |
description |
The localized technical behavior text of the spell (if available). | (Description text) |
⚙️ Core Technical Properties
Standard database values extracted directly from the primary Spell table records.
| Variable | Description | Example Values / Output |
|---|---|---|
icon |
The visual icon asset filename string. Forced automatic Title Case formatting applies natively. | Day_16_Magic_Arinas_Chosen
|
school |
The magic element or school category assigned to the spell. | day, night, etc.
|
rank |
The Tier/Rank tier level of the spell. | 5
|
used_on_map |
Boolean string indicating if the spell can be cast on the adventure map. | no / yes
|
is_special_magic |
Indicator flag for specialized restricted spell mechanics. | no
|
is_unique_magic |
Indicator flag for non-standard legendary or character-bound spells. | no
|
source_path |
The file path location of the repository data dump JSON. | DB/magics/battle_day_magics.json
|
💎 Resource Learning Costs
Resource costs required to memorize or master the spell path.
| Variable | Description | Example Value |
|---|---|---|
learn_cost_gemstones |
Amount of Gemstones required. | 10
|
learn_cost_crystals |
Amount of Crystals required. | 10
|
learn_cost_mercury |
Amount of Mercury required. | 10
|
---
Practical Examples
Example 1: Printing Localized Title
To display the Portuguese translated title of a specific high-tier spell:
{{#invoke:SpellData|get|day_16_magic_arinas_chosen|name|pt_br}}
Output: Escolhido de Arina
Example 2: Material Cost Validation Layout
You can easily print resource summaries using standard table modules:
* '''Gemstones cost:''' {{#invoke:SpellData|get|day_16_magic_arinas_chosen|learn_cost_gemstones}}
* '''Crystals cost:''' {{#invoke:SpellData|get|day_16_magic_arinas_chosen|learn_cost_crystals}}
local p = {}
-- Fonction locale pour formater automatiquement les icônes en Title Case
local function capitalize(str)
if not str then return "" end
local capitalized = str:gsub("(%a)([%w]*)", function(first, rest)
return first:upper() .. rest:lower()
end)
return capitalized
end
-- Fonction principale pour récupérer une donnée liée aux sorts
-- Syntaxe : {{#invoke:SpellData|get|ID_SORT|CHAMP|LANGUE}}
function p.get(frame)
local args = frame.args[1] and frame.args or frame:getParent().args
local spell_id = args[1]
local field = args[2]
local lang = args[3] or 'en' -- Anglais par défaut
if not spell_id or not field then
return "Erreur : ID de sort ou champ manquant."
end
-- 1. Gestion des champs textuels traduits (name, description)
if field == 'name' or field == 'description' then
local queryOpts = {
where = string.format('target_id="%s" AND language="%s" AND type="spell"', spell_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="spell"', spell_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 brutes de la table "Spell"
local spellOpts = {
where = string.format('id="%s"', spell_id)
}
local spellRes = mw.ext.cargo.query('Spell', field, spellOpts)
if spellRes and spellRes[1] and spellRes[1][field] then
local value = spellRes[1][field]
if field == 'icon' then
return capitalize(value)
end
return value
end
return ""
end
return p


