Module:Sandbox/User:Towelcat/TrailblazerQuestLine

Module documentation
This documentation is transcluded from Template:Module sandbox/doc. [edit] [history] [purge]
Module:Sandbox/User:Towelcat/TrailblazerQuestLine requires Module:Trailblazer Region.

This module is a sandbox for Towelcat. It can be used to test changes to existing modules, prototype new modules, or just experimenting with lua features.

Invocations of this sandbox should be kept in userspace; if the module is intended for use in other namespaces, it should be moved out of the sandbox into a normal module and template.

This default documentation can be overridden by creating the /doc subpage of this module, as normal.

local tb = require('Module:Trailblazer Region')._badge

local p = {}

function p.main(frame)
	local args = frame:getParent().args
	
	local regions = {'misthalin', 'karamja', 'asgarnia', 'desert', 'fremennik', 'kandarin', 'morytania', 'tirannwn', 'wilderness'}
	
	local ret = mw.html.create('tr')
	mw.log(args[1])
	if args['incompletable'] == 'Yes' then
		ret:tag('th'):wikitext(args[1]):addClass('table-bg-red')
	else ret:tag('th'):wikitext(args[1])
	end
	mw.log(tostring(ret))
	for _, region in ipairs(regions) do
		if args[region] == nil then
			if args['incompletable'] == 'Yes' then
				ret:tag('td'):addClass('table-bg-red')
			else ret:tag('td')
			end
		elseif args[region] == 'Yes' then
			ret:tag('td'):wikitext(tb(region,nil,nil,nil,'Trailblazer League (2020)'))
		elseif args[region] == 'auto' then
			ret:tag('td'):addClass('table-bg-green'):wikitext('Auto')
		else
			ret:tag('td'):wikitext(tb(region,nil,nil,nil,'Trailblazer League (2020)') .. ' ' .. args[region])
		end
	end
	if args['incompletable'] == 'Yes' then
		ret:tag('td'):wikitext(args['notes'] or ''):addClass('table-bg-red')
	else ret:tag('td'):wikitext(args['notes'] or '')
	end

	return tostring(ret)
end

return p