Module:Dye Gallery

From Brighter Shores Wiki
Jump to navigation Jump to search
Module documentation
This documentation is transcluded from Module:Dye Gallery/doc. [edit] [history] [purge]
This module does not have any documentation. Please consider adding documentation at Module:Dye Gallery/doc. [edit]
Module:Dye Gallery's function main is invoked by Template:Dye Gallery.

p = {}

function p.main(frame)
	return p._main(frame:getParent().args)
end

function p._main(args)
	
	-- sanitise inputs
	local stringBase = tostring(mw.title.getCurrentTitle())
	if args.base then
		stringBase = args.base
	end
	
	local stringMask = tostring(mw.title.getCurrentTitle()) .. ' dye'
	if args.mask then
		stringMask = args.mask
	elseif args.base then 
		stringMask = args.base .. ' dye'
	end
	
	-- complete image file path, currently unused
	-- Cannot combine these images in a Lua module, would have to be CSS or JS 
	local imageBaseHost = ('https://brightershoreswiki.org/images/%s.png'):format(stringBase)
	local imageMaskHost = ('https://brightershoreswiki.org/images/%s.png'):format(stringMask)

	-- output table
	local out = mw.html.create('table')
		:wikitext('This item can be dyed at [[The Color Wheel]] or [[City Dyes]]. It may also spawn with a random dye color.')
		:addClass('align-center-1 align-center-2')
		:tag('tr')
			:tag('td')
				:wikitext(('[[File:%s.png|264x264px]]'):format(stringBase))
			:done()
			:tag('td')
				:wikitext(('[[File:%s.png|264x264px]]'):format(stringMask))
			:done()
		:done()
		:tag('tr')
			:tag('td')
				:wikitext('The base appearance')
			:done()
			:tag('td')
				:wikitext('The dyable regions')
			:done()
		:done()
		
	return out
	
end

return p