編集の要約なし |
細編集の要約なし |
||
(3人の利用者による、間の9版が非表示) | |||
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( ' |
+ | args = require( 'モジュール:ProcessArgs' ).merge( true ) |
end |
end |
||
+ | local Reverselink = require( 'モジュール:Reverselink' ) |
||
− | local block = mw.text.trim( args[1] or '' ):lower() |
+ | local block = Reverselink.xlink( mw.text.trim( args[1] or '' ):lower() ) |
− | local |
+ | local argType = args.type |
− | |||
+ | local argName = args.name |
||
− | -- Most of these transforms are unnecessary, but are kept for compatibility with original template |
||
⚫ | |||
− | -- Strip trailing "s" on everything but these |
||
− | local |
+ | local value = values[block] |
− | 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$', '' ) |
||
⚫ | |||
− | |||
− | -- Other transforms |
||
− | block = block |
||
− | :gsub( 'wooden', 'wood' ) |
||
− | :gsub( 'mossy', 'moss' ) |
||
− | :gsub( 'steps', 'stairs' ) |
||
− | :gsub( "['%(%)%-%s]+", '' ) |
||
− | |||
⚫ | |||
local category = '' |
local category = '' |
||
if not value then |
if not value then |
||
− | value = |
+ | value = values[block:gsub( 's$', '' )] |
+ | |||
⚫ | |||
+ | if not value then |
||
⚫ | |||
− | + | value = '[[テンプレート:' .. argType .. ' values#欠損値|?]]' |
|
⚫ | |||
⚫ | |||
+ | category = '[[カテゴリ:' .. argName .. 'が不足しているページ]]' |
||
⚫ | |||
end |
end |
||
end |
end |
||
return value .. category |
return value .. category |
||
end |
end |
||
+ | |||
return p |
return p |
2020年3月11日 (水) 18:14時点における最新版
このモジュールは、{{hardness values}}
および {{blast resistance values}}
を実装しています。
依存関係
[閲覧 | 編集 | 履歴 | キャッシュ破棄]上記の解説は、モジュール:Block value/docから参照されています。
local p = {}
function p.value( f )
local args = f
if f == mw.getCurrentFrame() then
args = require( 'モジュール:ProcessArgs' ).merge( true )
end
local Reverselink = require( 'モジュール:Reverselink' )
local block = Reverselink.xlink( mw.text.trim( args[1] or '' ):lower() )
local argType = args.type
local argName = args.name
local values = mw.loadData( 'モジュール:' .. argType .. ' values' )
local value = values[block]
local category = ''
if not value then
value = values[block:gsub( 's$', '' )]
if not value then
value = '[[テンプレート:' .. argType .. ' values#欠損値|?]]'
local title = mw.title.getCurrentTitle()
if not args.nocat and title.namespace == 0 and not title.isSubpage then
category = '[[カテゴリ:' .. argName .. 'が不足しているページ]]'
end
end
end
return value .. category
end
return p