細編集の要約なし |
|||
(他の1人の利用者による、間の7版が非表示) | |||
1行目: | 1行目: | ||
local p = {} |
local p = {} |
||
+ | |||
⚫ | |||
+ | categoryUpcoming = 'カテゴリ:開発中', |
||
+ | defaultFuel = 'Any fuel', |
||
+ | moduleArgs = [[モジュール:ProcessArgs]], |
||
+ | moduleRecipe = [[モジュール:Recipe table]], |
||
+ | type = '製錬', |
||
⚫ | |||
+ | p.i18n = i18n |
||
+ | |||
+ | local recipeTable = require( i18n.moduleRecipe ).table |
||
+ | |||
function p.table( f ) |
function p.table( f ) |
||
local args = f |
local args = f |
||
if f == mw.getCurrentFrame() then |
if f == mw.getCurrentFrame() then |
||
− | args = |
+ | args = require( i18n.moduleArgs ).merge( true ) |
else |
else |
||
f = mw.getCurrentFrame() |
f = mw.getCurrentFrame() |
||
end |
end |
||
− | local grid = require( 'モジュール:Grid' ) |
||
⚫ | |||
− | -- Start table when appropriate |
||
⚫ | |||
− | local multirow = f:callParserFunction( '#dplvar', 'multirow' ) |
||
+ | args.Experience = args[3] |
||
− | if multirow ~= '1' then |
||
+ | args.Fuel = args.fuel or i18n.defaultFuel |
||
− | multirow = nil |
||
− | end |
||
− | local head = args.head or '' |
||
− | if multirow then |
||
− | head = '' |
||
− | elseif head ~= '' then |
||
− | multirow = 1 |
||
− | f:callParserFunction( '#dplvar:set', 'multirow', '1' ) |
||
− | else |
||
− | head = 1 |
||
− | end |
||
+ | local out = recipeTable( args, { |
||
− | -- End table when appropriate |
||
+ | uiFunc = 'furnace', |
||
− | local foot = args.foot or '' |
||
+ | type = i18n.type, |
||
− | if multirow then |
||
+ | ingredientArgs = { 'Input', 'Fuel' }, |
||
− | if foot ~= '' then |
||
+ | outputArgs = { 'Output' }, |
||
− | multirow = nil |
||
+ | } ) |
||
− | f:callParserFunction( '#dplvar:set', 'multirow', '0' ) |
||
− | end |
||
− | else |
||
− | foot = 1 |
||
− | end |
||
− | |||
− | local header = '' |
||
− | if head ~= '' then |
||
− | local name = '' |
||
− | local description = '' |
||
− | if args.showname == '1' or multirow and args.showname ~= '0' then |
||
− | name = '名前 !! ' |
||
− | f:callParserFunction( '#dplvar:set', 'smeltingname', '1' ) |
||
− | end |
||
− | if args.showdescription == '1' then |
||
− | description = ' !! class="unsortable" | 説明文' |
||
− | f:callParserFunction( '#dplvar:set', 'smeltingdescription', '1' ) |
||
− | end |
||
− | local class = args.class or '' |
||
− | local recipeClass = '' |
||
− | if multirow then |
||
− | class = 'sortable collapsible ' .. class |
||
− | recipeClass = 'class="unsortable collapse-button" |' |
||
− | end |
||
− | header = table.concat( { |
||
− | ' {| class="wikitable ' .. class .. '"', |
||
− | '! ' .. name .. '材料 !! ' .. recipeClass .. ' [[製錬]]レシピ' .. description, |
||
− | '|-' |
||
− | }, '\n' ) |
||
− | end |
||
− | |||
− | local input = mw.text.trim( args[1] or '' ) |
||
− | local output = mw.text.trim( args[2] or '' ) |
||
− | local fuel = args.fuel or '' |
||
− | if fuel == '' then |
||
− | fuel = 'いずれかの燃料' |
||
− | end |
||
− | |||
− | -- Name cell |
||
− | local nameCell |
||
− | if args.name or '' ~= '' then |
||
− | nameCell = args.name |
||
− | elseif multirow or f:callParserFunction( '#dplvar', 'smeltingname' ) == '1' then |
||
⚫ | |||
− | local links = {} |
||
− | for v in mw.text.gsplit( args[2] or '', '%s*;%s*' ) do |
||
− | parts = grid.getParts( v ) |
||
− | if not names[( parts.mod or '' ) .. parts.name] then |
||
− | local link = '' |
||
− | if parts.mod then |
||
− | link = 'Mods/' .. parts.mod .. '/' .. parts.name .. '|' |
||
− | end |
||
− | |||
− | if parts.name:find( '^いずれかの' ) then |
||
− | table.insert( links, 'いずれかの[[' .. link .. parts.name:sub( 5 ) .. ']]' ) |
||
− | else |
||
− | table.insert( links, '[[' .. link .. ']]' ) |
||
− | end |
||
− | names[( parts.mod or '' ) .. parts.name] = 1 |
||
− | end |
||
− | end |
||
− | |||
− | nameCell = table.concat( links, ' または<br>' ) |
||
− | end |
||
− | |||
− | if nameCell and args.upcoming then |
||
− | nameCell = nameCell .. '<br>([[' .. args.upcoming .. ']])' |
||
− | end |
||
− | |||
− | -- Ingredients cell |
||
− | local ingredientsCell |
||
− | if args.ingredients or '' ~= '' then |
||
− | ingredientsCell = args.ingredients |
||
− | else |
||
− | ingredientsCell = {} |
||
− | local ingredients = {} |
||
− | for k, v in ipairs{ input, fuel } do |
||
− | local separator = '' |
||
− | if k == 2 and next( ingredients ) then |
||
− | separator = ' +<br>\n' |
||
− | end |
||
− | for item in mw.text.gsplit( v, '%s*;%s*' ) do |
||
− | local parts = grid.getParts( item ) |
||
− | if parts.name ~= '' and not ingredients[parts.name] and ( k == 2 or k == 1 and v ~= fuel ) then |
||
− | local link = '' |
||
− | if separator == '' and next( ingredients ) then |
||
− | separator = ' または<br>\n' |
||
− | end |
||
− | |||
− | if parts.mod then |
||
− | link = 'Mods/'.. parts.mod .. '/' .. parts.name .. '|' |
||
− | end |
||
− | |||
− | if parts.name:find( '^いずれかの' ) then |
||
− | table.insert( ingredientsCell, separator .. 'いずれかの[[' .. link .. parts.name:sub( 5 ) .. ']]' ) |
||
− | else |
||
− | table.insert( ingredientsCell, separator .. '[[' .. link .. parts.name .. ']]' ) |
||
− | end |
||
− | separator = '' |
||
− | |||
− | ingredients[parts.name] = 1 |
||
− | end |
||
− | end |
||
− | end |
||
− | |||
− | ingredientsCell = table.concat( ingredientsCell ) |
||
− | end |
||
− | |||
− | -- Any args we want to pass along |
||
− | local newArgs = { |
||
⚫ | |||
⚫ | |||
− | Fuel = fuel, |
||
− | Ititle = args.Ititle, |
||
− | Otitle = args.Otitle, |
||
− | Ftitle = args.Ftitle |
||
⚫ | |||
− | |||
− | -- Recipe cell |
||
− | local recipeCell = grid.furnace( newArgs ) |
||
− | |||
− | local row = { ingredientsCell, recipeCell } |
||
− | if nameCell then |
||
− | table.insert( row, 1, nameCell ) |
||
− | end |
||
− | if f:callParserFunction( '#dplvar', 'smeltingdescription' ) == '1' then |
||
− | table.insert( row, args.description or '' ) |
||
− | end |
||
− | row = table.concat( row, '\n|\n' ) |
||
− | |||
− | if nameCell then |
||
− | row = '!\n' .. row |
||
− | else |
||
− | row = '|\n' .. row |
||
− | end |
||
− | |||
− | local footer = '' |
||
− | if foot ~= '' then |
||
− | footer = '|}' |
||
− | f:callParserFunction( '#dplvar:set', 'smeltingname', '0', 'smeltingdescription', '0' ) |
||
− | end |
||
local title = mw.title.getCurrentTitle() |
local title = mw.title.getCurrentTitle() |
||
− | local category |
+ | local category |
if args.upcoming and args.nocat ~= '1' and title.namespace == 0 and not title.isSubpage then |
if args.upcoming and args.nocat ~= '1' and title.namespace == 0 and not title.isSubpage then |
||
− | category = '[[ |
+ | category = '[[' .. i18n.categoryUpcoming .. ']]' |
end |
end |
||
− | return |
+ | return out, category |
end |
end |
||
+ | |||
return p |
return p |
2020年3月6日 (金) 14:12時点における最新版
local p = {}
local i18n = {
categoryUpcoming = 'カテゴリ:開発中',
defaultFuel = 'Any fuel',
moduleArgs = [[モジュール:ProcessArgs]],
moduleRecipe = [[モジュール:Recipe table]],
type = '製錬',
}
p.i18n = i18n
local recipeTable = require( i18n.moduleRecipe ).table
function p.table( f )
local args = f
if f == mw.getCurrentFrame() then
args = require( i18n.moduleArgs ).merge( true )
else
f = mw.getCurrentFrame()
end
args.Input = args[1]
args.Output = args[2]
args.Experience = args[3]
args.Fuel = args.fuel or i18n.defaultFuel
local out = recipeTable( args, {
uiFunc = 'furnace',
type = i18n.type,
ingredientArgs = { 'Input', 'Fuel' },
outputArgs = { 'Output' },
} )
local title = mw.title.getCurrentTitle()
local category
if args.upcoming and args.nocat ~= '1' and title.namespace == 0 and not title.isSubpage then
category = '[[' .. i18n.categoryUpcoming .. ']]'
end
return out, category
end
return p