Модуль:Загрузка Достижений

Материал из UnderMine Wiki
Перейти к навигации Перейти к поиску

Для документации этого модуля может быть создана страница Модуль:Загрузка Достижений/doc

return {
	main = function( frame )
		local args = frame
		if frame == mw.getCurrentFrame() then
			args = frame:getParent().args
		end
		local html = mw.html.create( 'div' )
		local frame = mw.getCurrentFrame()
		local templates = {
			'\n{| class="wikitable"\n',
			'! colspan="2" | [[Достижения]]\n'
		}
		for _, v in pairs(args) do
			local text = mw.text.trim(v)
			-- Header
			local title = mw.title.new( 'Достижения/' .. text, 'Template' )
			if title.exists then
				-- Image
				templates[#templates + 1] = (frame:expandTemplate{ title = 'Достижения/' .. text }):sub(2)
			else
				templates[#templates + 1] = '|-'
				templates[#templates + 1] = '| colspan="2" | Достижение "' .. text .. '" не найдено.[[Категория:Missing Achievement]]'
			end
		end
		templates[#templates + 1] = '|}'
		html = html:wikitext(table.concat(templates, "")):allDone()
		return html
	end,
}