Difference between revisions of "Module:SummonShowcase"
Jump to navigation
Jump to search
>TheLOLxd2 m (Cleanup) |
>TheLOLxd2 m (Cleanup) |
Revision as of 05:10, 8 April 2020
Documentation for this module may be created at Module:SummonShowcase/doc
-- <includeonly> (prevents literal interpretation of links or categories within the module code)
-- Lua Templating for {{SummonShowcase}}
local p = {}
local itemTemplate = '<div style="display:inline-block;vertical-align:top;width:80px;text-align:center;padding:4px">%s<br>[[%s]]</div>'
-- Usage: {{#invoke:SummonShowcase|Adventurers|<names,comma,separated>}}
-- Ex: {{#invoke:SummonShowcase|Adventurers|Halloween Mym, Halloween Lowen, Halloween Odetta, Halloween Elisanne}}
function p.Adventurers(frame)
local names = frame.args[1]
return p._Adventurers(names)
end
function p._Adventurers(names)
local result = {}
for name in mw.text.gsplit(names, ',') do
name = mw.text.trim(name)
if name ~= '' then
result[#result+1] = string.format(itemTemplate, icon('Adventurer', name), name)
end
end
return table.concat(result, '')
end
-- Usage: {{#invoke:SummonShowcase|Dragons|<names,comma,separated>}}
-- Ex: {{#invoke:SummonShowcase|Dragons|Halloween Maritimus, Halloween Silke}}
function p.Dragons(frame)
local names = frame.args[1]
return p._Dragons(names)
end
function p._Dragons(names)
local result = {}
for name in mw.text.gsplit(names, ',') do
name = mw.text.trim(name)
if name ~= '' then
result[#result+1] = string.format(itemTemplate, icon('Dragon', name), name)
end
end
return table.concat(result, '')
end
-- Usage: {{#invoke:SummonShowcase|Wyrmprints|<names,comma,separated>}}
-- Ex: {{#invoke:SummonShowcase|Wyrmprints|Witch's Kitchen}}
function p.Wyrmprints(frame)
local names = frame.args[1]
return p._Wyrmprints(names)
end
function p._Wyrmprints(names)
local result = {}
for name in mw.text.gsplit(names, ',') do
name = mw.text.trim(name)
if name ~= '' then
result[#result+1] = string.format(itemTemplate, icon('Wyrmprint', name), name)
end
end
return table.concat(result, '')
end
-- Common templating functions
-- {{Icon}}
function icon(type, name)
local frame = mw.getCurrentFrame()
return frame:expandTemplate{title='Icon', args={type, name}}
end
return p
--</includeonly>