Модуль:Al version

Матеріал з Minecraft Wiki
Перейти до навігації Перейти до пошуку
[створити] [оновити]Документація
Цей модуль не має документації. Якщо ви знаєте, як використовувати його, будь ласка, створіть її.
local p = {}

-- Raw version ({{al_version}})
function p.al_version(f)
    local args = f
    if f == mw.getCurrentFrame() then 
        args = require('Модуль:ProcessArgs' ).merge(true)
    end
    local version = mw.text.trim( args[1] or '' )
    
    -- load the values from the submodule
    local version_data = mw.loadData('Модуль:al_version/Версії').versions[version]
    
    local category = ''
    local value
    local title = mw.title.getCurrentTitle()
    
    if version_data then
        if version_data.ver then
    		if version_data.ver == 'Невідомо' then
    			value = 'Невідомо'
    			if not args.nocat and title.namespace == 0 and not title.isSubpage then
					category = '[[Категорія:Невідомі al_version]]'
				end
    		else
    	 		value = version_data.ver
			end
        else
            value = 'Н/Д'
        end
    else
        value = 'Невизначено'
        if not args.nocat and title.namespace == 0 and not title.isSubpage then
            category = '[[Категорія:Очікування al_version]]'
        end
    end
    return value .. category
end

-- Version table ({{al_version/table}})
function p.table(f)
    local args = f
    if f == mw.getCurrentFrame() then
        args = require('Модуль:ProcessArgs').merge(true)
    end
    
    local html = {}
    local values = mw.loadData('Модуль:al_version/Версії').list
    
    function table_header()
		table.insert(html, '<table class="wikitable sortable jquery-tablesorter">\n')
		table.insert(html, '<tr>\n')
		table.insert(html, ' <th>Game version</th>\n')
		table.insert(html, ' <th>al_version</th>\n')
		table.insert(html, '</tr>')
	end
	
	table.insert(html, '\n===Classic===\n')
	table_header()
	for _, version in ipairs(values) do
		if version.reset ~= nil then
			table.insert(html, '</table>')
			table.insert(html, '\n===Indev й Infdev===\n')
			table_header()
		end
		table.insert(html, '<tr>\n')
		table.insert(html, ' <td>[[' .. version.name .. ' (Java Edition)|' .. version.name .. ']]</td>')
		table.insert(html, ' <td style="text-align:center;">' .. version.ver .. '</td>')
		table.insert(html, '</tr>')
	end
	table.insert(html, '</table>')
	
	return table.concat(html)
end

return p