Module:IDInfo/Gadget

来自Minecraft基岩版开发Wiki
[创建 | 历史 | 清除缓存]文档页面
此模块没有文档页面。如果你知道如何使用模块,请创建它。
local p = {}
function p.Yesno( str, yes, no)
	local result = require( 'Module:Yesno' )( str, nil )
	if result == nil then
		return str
	elseif result then
		return yes or '是'
	else
		return no or '否'
	end
end
function p.Match( path, value, label, field )
	if value == nil then
		return nil
	end
	local jsondata = mw.text.jsonDecode(mw.title.makeTitle('Data', path):getContent() or '{}')
	for _, v in ipairs( jsondata ) do
		if type( v ) == 'table' and ( tostring( v[ label ] ) == tostring( value ) or v[ field ] == value ) and v[ label ] ~= nil and v[ field ] ~= nil then
			return tostring( v[ label ] ) .. ' (' .. v[ field ] .. ')'
		end
	end
	return value
end
function p.IconBar( value, icon, title )
	return mw.ustring.format(
		'%s (%s%s)',
		value,
		tostring( require('Module:Iconbar').bar( { full = icon, size = 9, value = value > 10 and 2 or value, title = value .. '点' .. title } ) ),
		value > 10 and ( '×' .. value / 2 ) or ''
	)
end
return p