Module:ListSeries

local p = {} require("Module:StrManip") require('Module:Card') local cargo = mw.ext.cargo --https://help.gamepedia.com/Extension:Cargo --https://www.mediawiki.org/wiki/Extension:Cargo

--cargo query by field function listBySeries(series) local qFields = "Name, Image, Type, SubType, Series, VA, Role" local qArgs = { where = "Series = '" .. tostring(series) .. "'",       orderBy = "Name", limit = 9000,

}   local lolis = cargo.query("loliInfo",qFields, qArgs) --mw.logObject(lolis) local root = mw.html.create('div') :cssText('display:flex; flex-flow:row wrap; hyphens:Auto;')

for i,loli in ipairs(lolis) do       mw.logObject(loli) root:Card(loli) end

return root end

--main function function p.listSeries local args = mw.getCurrentFrame.args[1] local qFields = "Series" local qArgs = { orderBy = "Series", limit = 10, --limit = 9000, }   local seriesAll = cargo.query("loliInfo",qFields, qArgs) mw.logObject(seriesAll) for i,series in ipairs(seriesAll) do       mw.logObject("AAA") end

--create one entry for each series local seriesList = {} for i,series in ipairs(seriesAll) do       local series = trim(series["Series"]:gsub(" -%(.*%) -",""):gsub(" -%[.*%] -",""):gsub(" -%{.*%} -","")) --mw.logObject(series) if not inTab(seriesList,series) then --mw.logObject(series .. " not yet added to list, adding") table.insert(seriesList,series) end end mw.logObject(seriesList)

--start to assemble list

local listString = "" for i,series in ipairs(seriesList) do       local localSeriesList = {} local cardString = "" for i,Lseries in ipairs(seriesAll) do           if Lseries["Series"]:find(series) then mw.logObject("series" .. Lseries["Series"]) table.insert(localSeriesList,Lseries["Series"]) end end for i,Lseries in ipairs(localSeriesList) do           cardString = cardString .. tostring(listBySeries(Lseries)) end mw.logObject(series) --listBySeries(series) --mw.logObject(listBySeries(series)) listString = listString .. "| style='height:12px;background:#70547c;border: 2px solid #70547c' colspan=2 |\n" listString = listString .. "|-\n" listString = listString .. "| style='background:#17111b;text-align:center;color:#eee;font-weight:bold;font-size:25px;font-family:%'Franklin Gothic%';border: 2px solid #70547c' colspan=2 | " .. series .. " \n" listString = listString .. "|-\n" listString = listString .. "| style='background:#70547c;border: #70547c 2px solid' | " .. cardString .. "\n" listString = listString .. "|-\n" end

--PROBLEM: I'm searching for exact matches in title, so anything that has a custom link isn't counted in the listbytype cargo query --is there a "contains" taht works in cargo query?

return listString end

return p