No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
mw.loadData('Module:Utility') | local util = mw.loadData('Module:Utility') | ||
function p.list(frame) | function p.list(frame) | ||
if frame.args.domain ~= nil then | if frame.args.domain ~= nil then | ||
local json = 'Module:Spell/Domain/' .. firstToUpper(frame.args['domain']) .. '.json' | local json = 'Module:Spell/Domain/' .. util.firstToUpper(frame.args['domain']) .. '.json' | ||
local spells = mw.loadJsonData(json) | local spells = mw.loadJsonData(json) | ||
Line 13: | Line 13: | ||
for spell_level,_ in ipairs(spells) do | for spell_level,_ in ipairs(spells) do | ||
table.insert(out, "| '''" .. formatLevel(spell_level-1) .. "''' \n|") | table.insert(out, "| '''" .. util.formatLevel(spell_level-1) .. "''' \n|") | ||
for spell_index, spell in ipairs(spells[spell_level]) do | for spell_index, spell in ipairs(spells[spell_level]) do | ||
Revision as of 12:27, 3 March 2023
Usage
{{#invoke:spell|list|domain=}}
{{#invoke:spell|list|category=}}
local p = {} local util = mw.loadData('Module:Utility') function p.list(frame) if frame.args.domain ~= nil then local json = 'Module:Spell/Domain/' .. util.firstToUpper(frame.args['domain']) .. '.json' local spells = mw.loadJsonData(json) local out = {} table.insert(out, '{| class="wikitable"\n! style="text-align:center" | Level !! style="text-align:center" | Spells\n|-\n') for spell_level,_ in ipairs(spells) do table.insert(out, "| '''" .. util.formatLevel(spell_level-1) .. "''' \n|") for spell_index, spell in ipairs(spells[spell_level]) do if spell_index > 1 then table.insert(out, "<br>") end table.insert(out, "[[" .. spell .. "]]") end table.insert(out, '\n|-\n') end table.insert(out, '|}') return table.concat(out) end end return p