Module:SpellTableUtil
From Heroes of Might and Magic: Olden Era Official Wiki
-- Module:SpellTableUtil/doc
SpellTableUtil Lua Module Documentation
This module provides dynamic spell tables and vertical infoboxes for HoMMOE spells using modular Lua spell data.
Usage
Spell Table
Displays a table of spells for a given school and tier.
{{#invoke:SpellTableUtil|spellTable|school=Arcane|tier=Tier 1}}
school: Spell school (Arcane, Daylight, Nightshade, Primal, Neutral)tier: Spell tier (e.g., Tier 1, Tier 2, ...)
Vertical Spell Infobox
Displays a vertical infobox for a single spell.
{{#invoke:SpellTableUtil|spellBoxV|name=Fireball}}
name: The canonical name of the spell.
Parameters
school(string): The spell school forspellTable.tier(string): The spell tier forspellTable.name(string): The spell name forspellBoxV.
Data Source
Spell data is loaded from the following modules:
Module:ArcaneSpellsModule:DaylightSpellsModule:NightshadeSpellsModule:PrimalSpellsModule:NeutralSpells
Table Columns
- Spell name (linked)
- Mana cost (with icon)
- Level 1-4 descriptions
Infobox Fields
- Spell name
- Spell icon
- School
- Tier
- Mana cost (with icon)
- Level 1-4 descriptions (if present)
Example
{{#invoke:SpellTableUtil|spellTable|school=Arcane|tier=Tier 1}}
{{#invoke:SpellTableUtil|spellBoxV|name=Fireball}}
Maintenance
To update spell data, edit the appropriate Lua module for the school.
This is the documentation page for Module:SpellTableUtil.
local p = {}
local moduleMap = {
Arcane = "Module:ArcaneSpells",
Daylight = "Module:DaylightSpells",
Nightshade = "Module:NightshadeSpells",
Primal = "Module:PrimalSpells",
Neutral = "Module:NeutralSpells"
}
-- Helper to find spell and its school
local function findSpellByName(name)
for school, moduleName in pairs(moduleMap) do
local spellsModule = require(moduleName)
local spells = spellsModule.spells or spellsModule
local spell = spells[name]
if spell then
return spell, school
end
end
return nil, nil
end
function p.spellTable(frame)
local school = frame.args["school"] or frame:getParent().args["school"]
local tier = frame.args["tier"] or frame:getParent().args["tier"]
local moduleName = moduleMap[school]
if not moduleName then
return "Unknown school: " .. tostring(school)
end
local spellsModule = require(moduleName)
local spells = spellsModule.spells or spellsModule
local html = '{| class="wikitable"\n' ..
'|+ ' .. school .. ' — ' .. tier .. '\n' ..
'|-\n' ..
'! Spell\n! align="center" | Mana Cost\n! Level 1\n! Level 2\n! Level 3\n! Level 4\n'
for _, spell in pairs(spells) do
if spell.tier == tier then
html = html ..
'|-\n| [[' .. spell.name .. ']]\n' ..
'| align="center" | [[File:Mana icon.png|32px]] ' .. (spell.mana or '–') .. '\n' ..
'| ' .. (spell.l1 or '') .. '\n' ..
'| ' .. (spell.l2 or '') .. '\n' ..
'| ' .. (spell.l3 or '') .. '\n' ..
'| ' .. (spell.l4 or '') .. '\n'
end
end
html = html .. '|}'
return html
end
function p.spellBoxV(frame)
local args = frame.args
local name = args.name or frame:getParent().args.name
local spell, school = findSpellByName(name)
if not spell then
return "Unknown spell: " .. tostring(name)
end
local spellIcon = name .. ".png"
local manaIcon = "Mana icon.png"
local schoolName = spell.school or school or "Unknown"
local tier = spell.tier or "–"
local mana = spell.mana or "–"
local html = '{| class="wikitable spellboxv" style="margin:1em auto; max-width:100%; background:#1a1a1a; color:#eee; border:2px solid #444; border-radius:8px; box-shadow:0 0 6px rgba(0,0,0,0.4); overflow-x:hidden;"\n'
html = html .. '|-\n| colspan=2 style="background:#304060; color:white; font-weight:bold; font-size:110%; text-align:center; padding:6px;" | ' .. spell.name .. '\n'
html = html .. '|-\n| colspan=2 align="center" style="padding:8px;" | [[File:' .. spellIcon .. '|64px]]\n'
html = html .. '|-\n| style="width:20%; font-weight:bold; text-align:left; background:#222;" | School || style="text-align:center;" | ' .. schoolName .. '\n'
html = html .. '|-\n| style="font-weight:bold; text-align:left; background:#222;" | Tier || style="text-align:center;" | ' .. tier .. '\n'
html = html .. '|-\n| style="font-weight:bold; text-align:left; background:#222;" | Mana || style="text-align:center;" | [[File:' .. manaIcon .. '|24px]] ' .. mana .. '\n'
-- Levels 1–4
for i = 1, 4 do
local key = "l" .. i
if spell[key] then
html = html .. '|-\n| style="font-weight:bold; text-align:left; background:#222;" | Level ' .. i ..
' || style="text-align:center;" | ' .. spell[key] .. '\n'
end
end
-- Masterful
if spell.masterful then
html = html .. '|-\n| style="font-weight:bold; text-align:left; background:#222;" | Masterful || style="text-align:center;" | ' .. spell.masterful .. '\n'
end
html = html .. '|}'
return html
end
return p


