Please note that some information on this wiki is still based on the demo version.
If you notice any errors, feel free to correct them.
Module:ItemList: Difference between revisions
From Super Fantasy Kingdom Official Wiki
Created page with "local p = {} function p.itemlist( f ) local args = f:getParent().args -- items can be one per arg or a comma separated list in one arg -- split first value at comma, e.g. from cargo list field local items = {} for v in mw.text.gsplit(args[1], ',', true) do if #v > 0 then -- ignore empty items table.insert(items, v) end end -- append other args for _,v in ipairs(args) do if _ > 1 and #v > 0 then table.insert(items, v) end end local output =..." |
return script |
||
| Line 27: | Line 27: | ||
return table.concat(output, '<br>') | return table.concat(output, '<br>') | ||
end | end | ||
return p | |||
Revision as of 21:54, 12 November 2025
Documentation for this module may be created at Module:ItemList/doc
local p = {}
function p.itemlist( f )
local args = f:getParent().args
-- items can be one per arg or a comma separated list in one arg
-- split first value at comma, e.g. from cargo list field
local items = {}
for v in mw.text.gsplit(args[1], ',', true) do
if #v > 0 then -- ignore empty items
table.insert(items, v)
end
end
-- append other args
for _,v in ipairs(args) do
if _ > 1 and #v > 0 then
table.insert(items, v)
end
end
local output = {}
for _,v in ipairs(items) do
table.insert(output, frame:expandTemplate{ title = 'ItemLink', args = { v } })
end
return table.concat(output, '<br>')
end
return p


