Module:SpellTableUtil: Difference between revisions
From Heroes of Might and Magic: Olden Era Official Wiki
HeavyBeber (talk | contribs) No edit summary Tag: Manual revert |
HeavyBeber (talk | contribs) No edit summary |
||
| Line 34: | Line 34: | ||
for _, spell in pairs(spells) do | for _, spell in pairs(spells) do | ||
if spell.tier == tier then | if spell.tier == tier then | ||
result = result .. "\n|-\n| [[ | result = result .. "\n|-\n| [[" .. spell.name .. "]]" | ||
result = result .. "\n| align=\"center\" |[[File:Mana icon.png|32px|link=Magic]] " .. spell.mana | result = result .. "\n| align=\"center\" |[[File:Mana icon.png|32px|link=Magic]] " .. spell.mana | ||
result = result .. "\n| " .. (spell.l1 or "") | result = result .. "\n| " .. (spell.l1 or "") | ||
Revision as of 11:43, 26 October 2025
-- 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 result = "{| 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"
for _, spell in pairs(spells) do
if spell.tier == tier then
result = result .. "\n|-\n| [[" .. spell.name .. "]]"
result = result .. "\n| align=\"center\" |[[File:Mana icon.png|32px|link=Magic]] " .. spell.mana
result = result .. "\n| " .. (spell.l1 or "")
result = result .. "\n| " .. (spell.l2 or "")
result = result .. "\n| " .. (spell.l3 or "")
result = result .. "\n| " .. (spell.l4 or "")
end
end
result = result .. "\n|}"
return result
end
function p.spellBoxV(frame)
local name = frame.args["name"] or frame:getParent().args["name"]
local spell, school = findSpellByName(name)
if not spell then
return "Unknown spell: " .. tostring(name)
end
local result = "{| class=\"spellboxv\" style=\"float:right; margin-left:1em;\"\n|+ " .. spell.name .. "\n|-\n| colspan=2 align=\"center\" |[[File:" .. (spell.image or "Mana icon.png") .. "|64px|link=Magic]]"
result = result .. "\n|-\n| <b>School</b> || " .. (spell.school or school)
result = result .. "\n|-\n| <b>Tier</b> || " .. spell.tier
result = result .. "\n|-\n| <b>Mana</b> || " .. spell.mana
result = result .. "\n|-\n| <b>Level 1</b> || " .. (spell.l1 or "")
result = result .. "\n|-\n| <b>Level 2</b> || " .. (spell.l2 or "")
result = result .. "\n|-\n| <b>Level 3</b> || " .. (spell.l3 or "")
result = result .. "\n|-\n| <b>Level 4</b> || " .. (spell.l4 or "")
result = result .. "\n|}"
return result
end
return p


