Module:Sandbox/Aurelain/SpellInfobox
From Heroes of Might and Magic: Olden Era Official Wiki
Documentation for this module may be created at Module:Sandbox/Aurelain/SpellInfobox/doc
-- This module is intended as a supporting muscle for the SpellInfobox template.
local p = {}
local UtilQuery = require('Module:UtilQuery')
-- Displays a variable
------------------------------------------------------------------------------------------------------------------------
local function dump(target)
return '<pre>' .. mw.dumpObject(target) .. '</pre>'
end
------------------------------------------------------------------------------------------------------------------------
local function getSpellEnglishName(spellId)
local table = UtilQuery.run([[
tables =
Translation = T
| where =
T.target_id = "%s"
AND T.language = 'en'
AND T.type = 'spell'
| fields =
T.name = name
| limit =
1
]], spellId)
return (table[1] or { name = '' }).name
end
------------------------------------------------------------------------------------------------------------------------
local function findMasterfulSpecializationText(spellNameEn)
local table = UtilQuery.run([[
tables =
Translation = T
| where =
T.description LIKE '%%starts with the %% %s%%"
AND T.language = 'en'
AND T.type = 'hero_specialization'
| fields =
T.description = description
| limit =
1
]], spellNameEn)
return (table[1] or { description = '' }).description
end
------------------------------------------------------------------------------------------------------------------------
function p.getMasterfulText(frame)
local spellId = frame.args.id
local spellNameEn = getSpellEnglishName(spellId)
local text = findMasterfulSpecializationText(spellNameEn)
return text
end
return p


