Module:Infobox gacha

From Sekaipedia
Revision as of 14:17, 15 September 2021 by YBamY (talk | contribs) (Gacha Start; Gacha End -> Start Date; End Date)

To generate {{Infobox gacha}}, invoke using the main function.


--------------------------
-- Module for [[Template:Infobox Gacha]]
------------------------
local getArgs   = require('Module:Arguments').getArgs
local builder   = require('Module:InfoboxBuilder')

local p = {}
local categories = ""

local function formatImage(image_name)
	return string.format("[[File:%s|220px]]", image_name)
end


function p.main(frame)
	local args = getArgs(frame)
	local infobox = builder.new()
	
	infobox:setName('Infobox Gacha')
		:setWidth("330px")
		:setParams{
			{ name = 'gacha id' },
			{ name = 'gacha name', default = mw.title.getCurrentTitle().text },
			{ name = 'image', func = formatImage },
			{ name = 'japanese' },
			{ name = 'romaji' },
			{ name = 'start' },
			{ name = 'end' },
			{ name = 'type' },
			{ name = 'festival' },
		}
		:setArgs(args)

	infobox
		:addHeader({ tag = 'argth', content = 'gacha name' })
		:addImage({
			{ tag = 'argtd', content = 'image' },
		})
		:addRow({
			{ tag = 'th', content = 'Japanese', colspan = 12 },
			{ tag = 'argtd', content = 'japanese', colspan = 18 }
		})
		:addRow({
			{ tag = 'th', content = 'Romaji', colspan = 12 },
			{ tag = 'argtd', content = 'romaji', colspan = 18 }
		})
		:addHeader({ tag = 'th', content = 'Gacha Information' }, { subheader = true })
		:addRow({
			{ tag = 'th', content = 'Start Date', colspan = 12 },
			{ tag = 'argtd', content = 'start', colspan = 18 }
		})
		:addRow({
			{ tag = 'th', content = 'End Date', colspan = 12 },
			{ tag = 'argtd', content = 'end', colspan = 18 }
		})
		:addRow({
			{ tag = 'th', content = 'Gacha Type', colspan = 12 },
			{ tag = 'argtd', content = 'type', colspan = 18 }
		})

	
	if mw.title.getCurrentTitle().namespace == 0 then
		categories = "[[Category:Gachas]]" .. categories
	end

	return infobox:tostring() .. categories
end

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