(ページの作成:「local p = {} local paramsGrp = { cookable = 'able', renewable = 'able', canspawn = 'can', gravity = 'can', transparent…」) |
The Non Useful (トーク | 投稿記録) 細編集の要約なし |
||
(4人の利用者による、間の11版が非表示) | |||
4行目: | 4行目: | ||
cookable = 'able', |
cookable = 'able', |
||
renewable = 'able', |
renewable = 'able', |
||
+ | |||
canspawn = 'can', |
canspawn = 'can', |
||
gravity = 'can', |
gravity = 'can', |
||
+ | lavasusceptible = 'can', |
||
transparent = 'can', |
transparent = 'can', |
||
+ | |||
['end support'] = 'some', |
['end support'] = 'some', |
||
⚫ | |||
['nether support'] = 'some', |
['nether support'] = 'some', |
||
dirt = true, |
dirt = true, |
||
light = true, |
light = true, |
||
+ | paid = true, |
||
['source available'] = true, |
['source available'] = true, |
||
['stackable'] = true, |
['stackable'] = true, |
||
− | + | flammable = true, |
|
+ | type = true, |
||
+ | behavior = true, |
||
+ | rarity = true |
||
} |
} |
||
27行目: | 33行目: | ||
noCan = 'しない', |
noCan = 'しない', |
||
noSome = 'なし', |
noSome = 'なし', |
||
+ | partial = '一部', |
||
yesDirt = '日光と土が必要', |
yesDirt = '日光と土が必要', |
||
yesLight = 'する(%s)', |
yesLight = 'する(%s)', |
||
yesLightP = 'する', |
yesLightP = 'する', |
||
+ | yesPaid = '有料', |
||
yesSource = '[%s 可]', |
yesSource = '[%s 可]', |
||
yesSourceP = '可', |
yesSourceP = '可', |
||
yesStackable = '可(%s)', |
yesStackable = '可(%s)', |
||
yesStackableP = '可', |
yesStackableP = '可', |
||
+ | yesFlammable = 'あり(%s)', |
||
+ | yesFlammableP = 'あり', |
||
noDirt = '日光と砂が必要', |
noDirt = '日光と砂が必要', |
||
noLight = 'しない', |
noLight = 'しない', |
||
+ | noPaid = '無料', |
||
noSource = '不可', |
noSource = '不可', |
||
noStackable = '不可', |
noStackable = '不可', |
||
+ | noFlammable = 'なし', |
||
type = { |
type = { |
||
− | armor = '防具', |
+ | armor = '防具', |
− | block = 'ブロック', |
+ | block = 'ブロック', |
− | ['block entity'] = 'ブロックエンティティ', |
+ | ['block entity'] = 'ブロックエンティティ', |
− | ['building block'] = '建築ブロック', |
+ | ['building block'] = '建築ブロック', |
− | combat = '戦闘', |
+ | combat = '戦闘', |
− | ['decoration block'] = '装飾ブロック', |
+ | ['decoration block'] = '装飾ブロック', |
− | decorations = '装飾', |
+ | decorations = '装飾', |
− | dyes = '染料', |
+ | dyes = '染料', |
− | entity = 'エンティティ', |
+ | entity = 'エンティティ', |
− | fluid = '液体', |
+ | fluid = '液体', |
− | food = '食料', |
+ | food = '食料', |
− | foodstuff = '食料', |
+ | foodstuff = '食料', |
− | item = 'アイテム', |
+ | item = 'アイテム', |
− | items = 'アイテム', |
+ | items = 'アイテム', |
− | ['non-solid block'] = '非 |
+ | ['non-solid block'] = '非固体ブロック', |
− | plant = '植物', |
+ | plant = '植物', |
− | plants = '植物', |
+ | plants = '植物', |
− | potions = 'ポーション', |
+ | potions = 'ポーション', |
− | projectile = '発射物', |
+ | projectile = '発射物', |
− | ['raw materials'] = '原材料', |
+ | ['raw materials'] = '原材料', |
− | manufactured |
+ | ['manufactured items'] = '加工品', |
− | ['solid block'] = ' |
+ | ['solid block'] = '固体ブロック', |
− | ['tile entity'] = 'タイルエンティティ', |
+ | ['tile entity'] = 'タイルエンティティ', |
− | tool = '道具', |
+ | tool = '道具', |
− | tools = '道具', |
+ | tools = '道具', |
− | transport = '運送', |
+ | transport = '運送', |
− | unknown = '不明', |
+ | unknown = '不明', |
− | vehicles = '乗り物', |
+ | vehicles = '乗り物', |
− | weapon = '武器', |
+ | weapon = '武器', |
− | ['wearable items'] = '装備品' |
+ | ['wearable items'] = '装備品' |
+ | }, |
||
+ | |||
+ | behavior = { |
||
+ | passive = '友好的', |
||
+ | defensive = '防衛的', |
||
+ | neutral = '中立的', |
||
+ | hostile = '敵対的' |
||
+ | }, |
||
+ | |||
+ | rarity = { |
||
+ | ['very common'] = '非常に一般的', |
||
+ | common = '一般的', |
||
+ | uncommon = '時々', |
||
⚫ | |||
+ | ['very rare'] = '非常にまれ', |
||
+ | epic = '稀少' |
||
} |
} |
||
} |
} |
||
95行目: | 123行目: | ||
if i18n.type[ val ] then |
if i18n.type[ val ] then |
||
return i18n.type[ val ] |
return i18n.type[ val ] |
||
⚫ | |||
+ | |||
+ | if i18n.behavior[ val ] then |
||
+ | return i18n.behavior[ val ] |
||
⚫ | |||
+ | |||
+ | if i18n.rarity[ val ] then |
||
+ | return i18n.rarity[ val ] |
||
end |
end |
||
104行目: | 140行目: | ||
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' |
||
123行目: | 160行目: | ||
lightLv = tonumber( lightLv ) |
lightLv = tonumber( lightLv ) |
||
− | + | result = ( lightLv and 0 < lightLv and lightLv < 16 ) |
|
− | return origVal |
||
⚫ | |||
− | |||
− | result = ( 0 < lightLv and lightLv < 16 ) |
||
and i18n.yesLight:format( lightLv ) or val == 'yes' |
and i18n.yesLight:format( lightLv ) or val == 'yes' |
||
and i18n.yesLightP or ( val == 'no' or lightLv == 0 ) |
and i18n.yesLightP or ( val == 'no' or lightLv == 0 ) |
||
and i18n.noLight or origVal |
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 |
elseif param == 'source available' then |
||
local link = val:match( '^%[(%S+)%s' ) |
local link = val:match( '^%[(%S+)%s' ) |
||
140行目: | 177行目: | ||
elseif param == 'stackable' then |
elseif param == 'stackable' then |
||
local stackSize = val:match( 'yes%s*%((%d+)%)' ) |
local stackSize = val:match( 'yes%s*%((%d+)%)' ) |
||
⚫ | |||
− | |||
⚫ | |||
− | return origVal |
||
⚫ | |||
− | |||
result = ( 0 < tonumber( stackSize ) and tonumber( stackSize ) <= 64 ) |
result = ( 0 < tonumber( stackSize ) and tonumber( stackSize ) <= 64 ) |
||
and i18n.yesStackable:format( stackSize ) or val == 'yes' |
and i18n.yesStackable:format( stackSize ) or val == 'yes' |
||
and i18n.yesStackableP or val == 'no' |
and i18n.yesStackableP or val == 'no' |
||
and i18n.noStackable or origVal |
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 |
end |
||
2023年7月20日 (木) 22:02時点における最新版
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'] = '非常にまれ',
epic = '稀少'
}
}
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