Module:Spell: Difference between revisions

From Kronopolis and the Flat Plane
No edit summary
No edit summary
Line 9: Line 9:
     local out = {}
     local out = {}


for i,v in pairs(spells) do
for i in pairs(spells) do
         table.insert(out, spells[v])
         table.insert(out, spells[i])
end
end



Revision as of 14:05, 24 February 2023

Usage

  • {{#invoke:spell|list|domain=}}
  • {{#invoke:spell|list|category=}}

local p = {}

function p.getDomainList(frame)
    local  json = frame.args[1]
    json = firstToUpper(json)
    json = 'Module:Spell/Domain/' .. json .. '.json'
    local spells = mw.loadJsonData(json)
    
    local out = {}

	for i in pairs(spells) do
        table.insert(out, spells[i])
	end

	return table.concat(out, "<br>")
end

function firstToUpper(str)
    return (str:gsub("^%l", string.upper))
end

return p