Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Character Card Grid: Difference between revisions

From Sekaipedia
Content added Content deleted
mNo edit summary
m (show name false)
Line 30: Line 30:
if #query > 0 then
if #query > 0 then
return cardGrid._main({
return cardGrid._main(
{
where = table.concat(query, ' AND ')
where = table.concat(query, ' AND ')
})
},
{
show_name = false
}
)
end
end

Revision as of 03:26, 24 September 2021

Documentation for this module may be created at Module:Character Card Grid/doc

local getArgs   = require('Module:Arguments').getArgs
local cardGrid  = require('Module:Card Grid')

local p = {}

local function createQueryPart(arg, cargo_col)
	local list = mw.text.split(arg, ',')
	
	for i,v in ipairs(list) do
		local temp_v = string.gsub(string.gsub(mw.text.trim(v), ',', ','), "'", "\\'")
		list[i] = string.format("Cards.%s = '%s'", cargo_col, temp_v)
	end

	return '(' .. table.concat(list, ' OR ') .. ')'
end

function p.main(frame)
	local args = getArgs(frame)
	
	local lists = {}
	local query = {}
	
	if args['characters'] and args['characters'] ~= '' then
		table.insert(query, createQueryPart(args['characters'], 'card_character'))
	end
	
	if args['rarities'] and args['rarities'] ~= '' then
		table.insert(query, createQueryPart(args['rarities'], 'rarity'))
	end
	
	if #query > 0 then
		return cardGrid._main(
			{
				where = table.concat(query, ' AND ')
			},
			{
				show_name = false
			}
		)
	end
	
	return nil
end

return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.