Minecraft Wiki

除另有声明,转载时均必须注明出处若簡繁轉換出錯,請以遊戲內為準请勇于扩充与修正内容有兴趣逛逛我们的微博沟通交流,欢迎到社区专页需要协助,请在告示板留言

了解更多

Minecraft Wiki
(test)
 
(未显示4个用户的6个中间版本)
第1行: 第1行:
 
local p = {}
 
local p = {}
  +
p.value = function( f )
 
  +
function p.value( f )
 
local args = f
 
local args = f
 
if f == mw.getCurrentFrame() then
 
if f == mw.getCurrentFrame() then
 
args = require( 'Module:ProcessArgs' ).merge( true )
 
args = require( 'Module:ProcessArgs' ).merge( true )
 
end
 
end
local block = mw.text.trim( args[1])
+
local block = mw.text.trim( args[1] or '' ):lower()
local type = args.type
+
local argType = args.type
 
-- Most of these transforms are unnecessary, but are kept for compatibility with original template
 
 
-- Strip trailing "s" on everything but these
 
local keepS = {
 
glass = true,
 
steps = true, stairs = true,
 
bars = true,
 
cactus = true,
 
leaves = true,
 
grass = true,
 
potatoes = true
 
}
 
if not keepS[block:match( '%w+$' )] then
 
block = block:gsub( 's$', '' )
 
end
 
 
-- Other transforms
 
block = block
 
:gsub( 'wooden', 'wood' )
 
:gsub( 'mossy', 'moss' )
 
:gsub( 'steps', 'stairs' )
 
:gsub( "['%(%)%-%s]+", '' )
 
 
 
local value = mw.loadData( 'Module:' .. type .. ' values' )[block]
+
local values = mw.loadData( 'Module:' .. argType .. ' values' )
  +
local value = values[block]
 
local category = ''
 
local category = ''
 
if not value then
 
if not value then
value = '[[Template:' .. type .. ' values#缺失的值|?]]'
+
value = values[block:gsub( 's$', '' )]
  +
local title = mw.title.getCurrentTitle()
 
  +
if not value then
if not args.nocat and title.namespace == 0 and not title.isSubpage then
 
category = '[[Category:缺失 ' .. type:lower() .. ']]'
+
value = '[[Template:' .. argType .. ' values#缺失值|?]]'
 
local title = mw.title.getCurrentTitle()
 
if not args.nocat and title.namespace == 0 and not title.isSubpage then
  +
category = '[[Category:缺失' .. argType:lower() .. ']]'
 
end
 
end
 
end
 
end
 
end
 
return value .. category
 
return value .. category
 
end
 
end
  +
 
return p
 
return p

2020年3月4日 (三) 16:12的最新版本

本模块用于实现{{hardness values}}{{blast resistance values}}

依赖项[]

local p = {}

function p.value( f )
	local args = f
	if f == mw.getCurrentFrame() then 
		args = require( 'Module:ProcessArgs' ).merge( true )
	end
	local block = mw.text.trim( args[1] or '' ):lower()
	local argType = args.type
	
	local values = mw.loadData( 'Module:' .. argType .. ' values' )
	local value = values[block]
	local category = ''
	if not value then
		value = values[block:gsub( 's$', '' )]
		
		if not value then
			value = '[[Template:' .. argType .. ' values#缺失值|?]]'
			local title = mw.title.getCurrentTitle()
			if not args.nocat and title.namespace == 0 and not title.isSubpage then
				category = '[[Category:缺失' .. argType:lower() .. ']]'
			end
		end
	end
	return value .. category
end

return p