Module:Items

local p = {} local cargo = mw.ext.cargo

function toTable(s) local result = {}; local delimiter1 = ','; local delimiter2 = '='; local ind = ''; local val = ''; for match1 in (s..delimiter1):gmatch("(.-)"..delimiter1) do   	for match2 in (match1..delimiter2):gmatch("(.-)"..delimiter2) do    		if ind ~= '' then ind = match2; elseif val ~= '' then val = match2; else result[ind] = val; end end end return result; end

function trimBrackets(s) error(s) local ls = string.gsub("%[",s); local rs = string.gsub("%]",ls); return rs; end

function p.items(frame) local restbl = ''; local fstr = frame.args[2]; trimBrackets(frame.args[3]); trimBrackets(frame.args[4]); local results = cargo.query(frame.args[1], trimBrackets(frame.args[3]), toTable(trimBrackets(frame.args[4]))); for r = 1, #results do       local result = results[r]; -- Do something with the result table, e.g. result.alias1 end return restbl; -- Items/format end

return p