Minecraft Wiki

Minecraft Wiki ภาษาไทยกำลังจะย้ายออกจาก Fandom ตามภาษาอังกฤษในเร็ว ๆ นี้ ดูที่หน้านี้และ Discord สำหรับข้อมูลเพิ่มเติม

READ MORE

Minecraft Wiki
Advertisement
[ดู | แก้ไข | ประวัติ | ล้างแคช]คู่มือการใช้งานJump to code ↴

This module implements {{Protocol version}}, {{Data version}}, and {{Protocol version/Table}}.

The actual data used by this module is stored in Module:Protocol version/Versions.

See also[]

[ดู | แก้ไข | ประวัติ | ล้างแคช]คู่มือการใช้งานที่ปรากฏด้านบนนี้ดึงมาจาก มอดูล:Protocol version/doc.
local p = {}

-- {{Protocol version}}
function p.protocol_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 subมอดูล
	local version_data = mw.loadData('มอดูล:Protocol version/Versions').versions[version]

	local category = ''
	local value
	local title = mw.title.getCurrentTitle()

	if version_data then
		if version_data.protocol then
			if version_data.protocol == 'ไม่ทราบ' then
				value = '[[แม่แบบ:Protocol version#Unknown version|ไม่ทราบ]]'
				if not args.nocat and title.namespace == 0 and not title.isSubpage then
					category = '[[หมวดหมู่:ไม่ทราบเวอร์ชันโพรโทคอล]]'
				end
			else
				value = version_data.protocol
			end
		else
			value = 'N/A'
		end
	else
		value = '[[แม่แบบ:Protocol version#Unknown version|กำลังรอ]]'
		if not args.nocat and title.namespace == 0 and not title.isSubpage then
			category = '[[หมวดหมู่:กำลังรอเวอร์ชันโพรโทคอล]]'
		end
	end
	return value .. category
end

-- {{Data version}}
function p.data_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 subมอดูล
	local version_data = mw.loadData('มอดูล:Protocol version/Versions').versions[version]

	local category = ''
	local value
	local title = mw.title.getCurrentTitle()

	if version_data then
		if version_data.data then
			if version_data.data == 'ไม่ทราบ' then
				value = '[[แม่แบบ:Data version#Unknown version|ไม่ทราบ]]'
				if not args.nocat and title.namespace == 0 and not title.isSubpage then
					category = '[[หมวดหมู่:ไม่ทราบเวอร์ชันดาต้า]]'
				end
			else
				value = version_data.data
			end
		else
			value = 'N/A'
		end
	else
		value = '[[แม่แบบ:Data version#Unknown version|กำลังรอ]]'
		if not args.nocat and title.namespace == 0 and not title.isSubpage then
			category = '[[หมวดหมู่:กำลังรอเวอร์ชันดาต้า]]'
		end
	end
	return value .. category
end

-- Version table ({{Protocol version/table}})
function p.table(f)
	local args = f
	if f == mw.getCurrentFrame() then
		args = require('มอดูล:ProcessArgs').merge(true)
	end

	local html = {}
	local groups = mw.loadData('มอดูล:Protocol version/Versions').groups

	for _, group in ipairs(groups) do
		local include = true
		if #args ~= 0 then
			include = nil
			for __, name in ipairs(args) do
				if name == group.name then
					include = true
					break
				end
			end
		end

		if include then
			if not args.notitle then
				table.insert(html, '=== [[' .. group.link .. '|' .. group.name .. ']] ===\n')
			end
			if group.desc ~= nil then
				table.insert(html, group.desc .. '\n')
			end
			table.insert(html, "<table class='wikitable sortable jquery-tablesorter'>\n")
			table.insert(html, '<tr>\n')
			table.insert(html, '<th>เวอร์ชันไคลเอนต์</th>\n')
			table.insert(html, '<th>[[เวอร์ชันโพรโทคอล]]</th>\n')
			if group.has_data_versions then
				table.insert(html, '<th>[[เวอร์ชันดาต้า]]</th>\n')
			end
			table.insert(html, '</tr>\n')

			local num_same_protocol
			local last_protocol = -1
			local protocol_row

			local num_same_data
			local last_data = -1
			local data_row

			for __, version in ipairs(group.values) do
				table.insert(html, '<tr>')
				table.insert(html, '<td>[[' .. version.name .. ']]</td>\n')
				if version.protocol ~= last_protocol or version.force_split_protocol then
					last_protocol = version.protocol
					num_same_protocol = 1
					table.insert(html, '<td style="text-align:center">' .. version.protocol .. '</td>\n')
					protocol_row = #html
				else
					num_same_protocol = num_same_protocol + 1
					html[protocol_row] = '<td style="text-align:center" rowspan="' .. num_same_protocol .. '">' .. version.protocol .. '</td>\n'
				end
				if group.has_data_versions then
					if version.data then
						if version.data ~= last_data then
							last_data = version.data
							num_same_data = 1
							table.insert(html, '<td style="text-align:center">' .. version.data .. '</td>\n')
							data_row = #html
						else
							num_same_data = num_same_data + 1
							html[data_row] = '<td style="text-align:center" rowspan="' .. num_same_data .. '">' .. version.data .. '</td>\n'
						end
					else
						if last_data ~= 'N/A' then
							last_data = 'N/A'
							num_same_data = 1
							table.insert(html, '<td style="text-align:center">N/A</td>\n')
							data_row = #html
						else
							num_same_data = num_same_data + 1
							html[data_row] = '<td style="text-align:center" rowspan="' .. num_same_data .. '">' .. "N/A </td>\n"
						end
					end
				end
				table.insert(html, '</tr>\n')
			end

			table.insert(html, '</table>\n')
		end
	end

	return table.concat(html)
end

return p
Advertisement