(flammable) |
(+rarity) |
||
(同じ利用者による、間の1版が非表示) | |||
20行目: | 20行目: | ||
flammable = true, |
flammable = true, |
||
type = true, |
type = true, |
||
− | behavior = true |
+ | behavior = true, |
+ | rarity = true |
||
} |
} |
||
32行目: | 33行目: | ||
noCan = 'しない', |
noCan = 'しない', |
||
noSome = 'なし', |
noSome = 'なし', |
||
+ | partial = '一部', |
||
yesDirt = '日光と土が必要', |
yesDirt = '日光と土が必要', |
||
88行目: | 90行目: | ||
neutral = '中立的', |
neutral = '中立的', |
||
hostile = '敵対的' |
hostile = '敵対的' |
||
+ | }, |
||
+ | |||
+ | rarity = { |
||
+ | ['very common'] = '非常に一般的', |
||
+ | common = '一般的', |
||
+ | uncommon = '時々', |
||
+ | rare = 'まれ', |
||
+ | ['very rare'] = '非常にまれ' |
||
} |
} |
||
} |
} |
||
116行目: | 126行目: | ||
if i18n.behavior[ val ] then |
if i18n.behavior[ val ] then |
||
return i18n.behavior[ val ] |
return i18n.behavior[ val ] |
||
+ | end |
||
+ | |||
+ | if i18n.rarity[ val ] then |
||
+ | return i18n.rarity[ val ] |
||
end |
end |
||
125行目: | 139行目: | ||
elseif paramsGrp[ param ] == 'can' then |
elseif paramsGrp[ param ] == 'can' then |
||
result = val == 'yes' |
result = val == 'yes' |
||
− | and i18n.yesCan or val == 'no' |
+ | and i18n.yesCan or val == 'no' |
− | and i18n.noCan or |
+ | and i18n.noCan or val == 'partial' |
+ | and i18n.partial or origVal |
||
elseif paramsGrp[ param ] == 'some' then |
elseif paramsGrp[ param ] == 'some' then |
||
result = val == 'yes' |
result = val == 'yes' |
2020年5月18日 (月) 13:49時点における版
local p = {}
local paramsGrp = {
cookable = 'able',
renewable = 'able',
canspawn = 'can',
gravity = 'can',
lavasusceptible = 'can',
transparent = 'can',
['end support'] = 'some',
['nether support'] = 'some',
dirt = true,
light = true,
paid = true,
['source available'] = true,
['stackable'] = true,
flammable = true,
type = true,
behavior = true,
rarity = true
}
local i18n = {
na = '?',
yesAble = '可',
yesCan = 'する',
yesSome = 'あり',
noAble = '不可',
noCan = 'しない',
noSome = 'なし',
partial = '一部',
yesDirt = '日光と土が必要',
yesLight = 'する(%s)',
yesLightP = 'する',
yesPaid = '有料',
yesSource = '[%s 可]',
yesSourceP = '可',
yesStackable = '可(%s)',
yesStackableP = '可',
yesFlammable = 'あり(%s)',
yesFlammableP = 'あり',
noDirt = '日光と砂が必要',
noLight = 'しない',
noPaid = '無料',
noSource = '不可',
noStackable = '不可',
noFlammable = 'なし',
type = {
armor = '防具',
block = 'ブロック',
['block entity'] = 'ブロックエンティティ',
['building block'] = '建築ブロック',
combat = '戦闘',
['decoration block'] = '装飾ブロック',
decorations = '装飾',
dyes = '染料',
entity = 'エンティティ',
fluid = '液体',
food = '食料',
foodstuff = '食料',
item = 'アイテム',
items = 'アイテム',
['non-solid block'] = '非固体ブロック',
plant = '植物',
plants = '植物',
potions = 'ポーション',
projectile = '発射物',
['raw materials'] = '原材料',
['manufactured items'] = '加工品',
['solid block'] = '固体ブロック',
['tile entity'] = 'タイルエンティティ',
tool = '道具',
tools = '道具',
transport = '運送',
unknown = '不明',
vehicles = '乗り物',
weapon = '武器',
['wearable items'] = '装備品'
},
behavior = {
passive = '友好的',
defensive = '防衛的',
neutral = '中立的',
hostile = '敵対的'
},
rarity = {
['very common'] = '非常に一般的',
common = '一般的',
uncommon = '時々',
rare = 'まれ',
['very rare'] = '非常にまれ'
}
}
function p.conv( f )
local args = require( 'Module:ProcessArgs' ).merge( true )
local param = args[ 1 ]
local origVal = args[ 2 ]
local val = origVal
local result
if not param or not origVal then
if param == 'flammable' then
return i18n.noSome
elseif param and paramsGrp[ param:lower() ] then
return i18n.na
end
return origVal or ''
end
param = param:lower()
val = val:lower()
if i18n.type[ val ] then
return i18n.type[ val ]
end
if i18n.behavior[ val ] then
return i18n.behavior[ val ]
end
if i18n.rarity[ val ] then
return i18n.rarity[ val ]
end
-- Normal yes/no check
if paramsGrp[ param ] == 'able' then
result = val == 'yes'
and i18n.yesAble or val == 'no'
and i18n.noAble or origVal
elseif paramsGrp[ param ] == 'can' then
result = val == 'yes'
and i18n.yesCan or val == 'no'
and i18n.noCan or val == 'partial'
and i18n.partial or origVal
elseif paramsGrp[ param ] == 'some' then
result = val == 'yes'
and i18n.yesSome or val == 'no'
and i18n.noSome or origVal
end
if result then return result end
-- Special yes/no check
if param == 'dirt' then
result = val == 'yes'
and i18n.yesDirt or val == 'no'
and i18n.noDirt or origVal
elseif param == 'light' then
local lightLv = val:match( '^%d+$' ) or val:match( 'yes,?%s*%(?(%d+)%)?' )
lightLv = tonumber( lightLv )
result = ( lightLv and 0 < lightLv and lightLv < 16 )
and i18n.yesLight:format( lightLv ) or val == 'yes'
and i18n.yesLightP or ( val == 'no' or lightLv == 0 )
and i18n.noLight or origVal
elseif param == 'paid' then
result = ( val == 'yes' or val == 'はい' )
and i18n.yesPaid or ( val == 'no' or val == 'いいえ' )
and i18n.noPaid or origVal
elseif param == 'source available' then
local link = val:match( '^%[(%S+)%s' )
local text = val:match( '%s(.+)%]$' )
result = text == 'yes'
and i18n.yesSource:format( link ) or val == 'yes'
and i18n.yesSourceP or val == 'no'
and i18n.noSource or origVal
elseif param == 'stackable' then
local stackSize = val:match( 'yes%s*%((%d+)%)' )
stackSize = stackSize or 0
result = ( 0 < tonumber( stackSize ) and tonumber( stackSize ) <= 64 )
and i18n.yesStackable:format( stackSize ) or val == 'yes'
and i18n.yesStackableP or val == 'no'
and i18n.noStackable or origVal
elseif param == 'flammable' then
local encouragement = val:match( 'yes,?%s*%(?(%d+)%)' )
encouragement = tonumber( encouragement )
result = ( encouragement ~= nil )
and i18n.yesFlammable:format( encouragement ) or ( val == 'yes' or val == 'する' )
and i18n.yesFlammableP or ( val == 'no' or val == 'しない' )
and i18n.noFlammable or origVal
end
return result or origVal
end
return p