Module:Itemlist

local getArgs = require('Module:Arguments').getArgs local p = {}

function p.main(frame) local args = getArgs(frame) return p._main(args) end

function p._main(args)

local text = args["text"] or "Box items:" local i = 0 local list = {} local pages = mw.loadData('Module:IS/pages')

for _, arg in pairs(args) do		i = i+1 local item = args[i] local sprite = args[i] if string.match(item, "^%d+") then quantity = tonumber(string.match(item, "^%d+")) if quantity > 1 then for _,page in pairs(pages) do					for _, i in pairs (page.items) do						if string.match(item, "^%d+ "..i.."s?") then sprite = string.gsub(item, "^%d+ ".."("..i..")".."s?", "%1") end end end end end local sprite = mw.getCurrentFrame:expandTemplate{ title = "IS", args = { sprite } } table.insert(list, "*"..sprite.." "..item) end

list = table.concat(list, "\n") return mw.getCurrentFrame:expandTemplate{ title = "collapse", args = { text, list } } end return p

-- print(p.main)