Difference between revisions of "Module:SummonShowcase"
Jump to navigation
Jump to search
>Eave (Created page with "-- <includeonly> (prevents literal interpretation of links or categories within the module code) -- Lua Templating for {{Template:SummonShowcase}} local p = {} local itemTemp...") |
>TheLOLxd2 m (Cleanup) |
||
| (3 intermediate revisions by one other user not shown) | |||
| Line 1: | Line 1: | ||
-- <includeonly> (prevents literal interpretation of links or categories within the module code) | -- <includeonly> (prevents literal interpretation of links or categories within the module code) | ||
| − | -- Lua Templating for {{ | + | -- Lua Templating for {{SummonShowcase}} |
local p = {} | local p = {} | ||
| Line 17: | Line 17: | ||
for name in mw.text.gsplit(names, ',') do | for name in mw.text.gsplit(names, ',') do | ||
name = mw.text.trim(name) | name = mw.text.trim(name) | ||
| − | result[#result+1] = string.format(itemTemplate, icon('Adventurer', name), name) | + | if name ~= '' then |
| + | result[#result+1] = string.format(itemTemplate, icon('Adventurer', name), name) | ||
| + | end | ||
end | end | ||
| Line 35: | Line 37: | ||
for name in mw.text.gsplit(names, ',') do | for name in mw.text.gsplit(names, ',') do | ||
name = mw.text.trim(name) | name = mw.text.trim(name) | ||
| − | result[#result+1] = string.format(itemTemplate, icon('Dragon', name), name) | + | if name ~= '' then |
| + | result[#result+1] = string.format(itemTemplate, icon('Dragon', name), name) | ||
| + | end | ||
end | end | ||
| Line 53: | Line 57: | ||
for name in mw.text.gsplit(names, ',') do | for name in mw.text.gsplit(names, ',') do | ||
name = mw.text.trim(name) | name = mw.text.trim(name) | ||
| − | result[#result+1] = string.format(itemTemplate, icon('Wyrmprint', name), name) | + | if name ~= '' then |
| + | result[#result+1] = string.format(itemTemplate, icon('Wyrmprint', name), name) | ||
| + | end | ||
end | end | ||
| Line 62: | Line 68: | ||
-- Common templating functions | -- Common templating functions | ||
| − | -- {{ | + | -- {{Icon}} |
function icon(type, name) | function icon(type, name) | ||
local frame = mw.getCurrentFrame() | local frame = mw.getCurrentFrame() | ||
Latest 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>