Module:Spell: Difference between revisions

From Kronopolis and the Flat Plane
No edit summary
No edit summary
Line 2: Line 2:


function p.getDomainList(frame)
function p.getDomainList(frame)
     local page = 'Module:Spell/domain-' .. frame.args[1] .. '.json'
     local json = frame.args[1]
     local data = mw.loadJsonData(page)
    json = firstToUpper(json)
    json = 'Module:Spell/Domain/' .. json .. '.json'
     local data = mw.loadJsonData(json)
      
      
     local out = {}
     local out = {}
Line 12: Line 14:


return table.concat(out, "<br>")
return table.concat(out, "<br>")
end
function firstToUpper(str)
    return (str:gsub("^%l", string.upper))
end
end


return p
return p

Revision as of 13:20, 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 data = mw.loadJsonData(json)
    
    local out = {}

	for idx = 1, 5 do
		table.insert(out, idx)
	end

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

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

return p