mNessun oggetto della modifica |
mNessun oggetto della modifica |
||
(29 versioni intermedie di 4 utenti non mostrate) | |||
Riga 1: | Riga 1: | ||
local p = {} |
local p = {} |
||
− | local slot = require( [[Modulo:Inventory slot]] ) |
||
− | local getParts = slot.getParts |
||
− | local prefixes = slot.prefixes |
||
+ | local i18n = { |
||
− | local function prefixedLink( name, mod ) |
||
− | + | colored = 'Colorato', |
|
+ | coloredDyes = { |
||
− | for _, thisPrefix in pairs( prefixes ) do |
||
+ | 'Colorante arancione', 'Colorante magenta', 'Colorante azzurro', 'Colorante giallo', 'Colorante lime', |
||
− | if name:find( '^' .. thisPrefix .. ' ' ) then |
||
+ | 'Colorante rosa', 'Colorante grigio', 'Colorante grigio chiaro', 'Colorante ciano', 'Colorante viola', |
||
− | prefix = thisPrefix .. ' ' |
||
+ | 'Colorante blu', 'Colorante marrone', 'Colorante verde', |
||
− | name = name:gsub( '^' .. prefix, '' ) |
||
+ | 'Colorante rosso', 'Colorante nero', |
||
− | break |
||
+ | }, |
||
− | end |
||
+ | categoryIngredientUsage = 'Categoria:Ricetta che usa $1', |
||
− | end |
||
+ | categoryRecipeType = 'Categoria:Ricetta di $1', |
||
− | |||
+ | categoryUpcoming = 'Categoria:In arrivo', |
||
− | local page = '' |
||
+ | itemBlockOfQuartz = 'Blocco di quarzo', |
||
− | if mod and mod ~= '' then |
||
+ | itemBrownMushroom = 'Fungo marrone', |
||
− | page = 'Modifiche/' .. mod .. '/' |
||
+ | itemCharcoal = 'Carbonella', |
||
− | end |
||
+ | itemCoal = 'Carbone', |
||
− | |||
+ | itemColoredDye = 'Colorante', |
||
− | return prefix .. '[[' .. page .. name .. '|' .. name .. ']]' |
||
+ | itemDye = 'Colorante', |
||
− | end |
||
+ | itemMushroom = 'Fungo', |
||
+ | itemQuartzBlock = 'Blocco di quarzo', |
||
+ | itemRedMushroom = 'Fungo rosso', |
||
+ | itemStone = 'Pietra', |
||
+ | itemWhiteDye = 'Colorante bianco', |
||
+ | moduleArgs = [[Modulo:ProcessArgs]], |
||
+ | moduleRecipe = [[Modulo:Recipe table]], |
||
+ | moduleSlot = [[Modulo:Inventory slot]], |
||
+ | stoneVariants = { 'Pietra', 'Andesite', 'Granito', 'Diorite' }, |
||
+ | type = 'Fabbricazione', |
||
+ | variantPages = { |
||
+ | 'Andesite', 'Stendardo', 'Letto', 'Diorite', 'Stella pirotecnica', 'Granito', |
||
+ | 'Pedana a pressione', 'Sabbia', 'Arenaria', 'Scudo', 'Lastra', 'Pannello di vetro', |
||
+ | 'Vetro', 'Scalini', 'Mattoni di pietra', 'Assi di legno', 'Legno', 'Lana', |
||
+ | }, |
||
+ | } |
||
+ | p.i18n = i18n |
||
+ | |||
+ | local slot = require( i18n.moduleSlot ) |
||
+ | local recipeTable = require( i18n.moduleRecipe ).table |
||
+ | local cArgVals = { 'A1', 'B1', 'C1', 'A2', 'B2', 'C2', 'A3', 'B3', 'C3' } |
||
+ | p.cArgVals = cArgVals |
||
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 = require( |
+ | args = require( i18n.moduleArgs ).merge( true ) |
else |
else |
||
f = mw.getCurrentFrame() |
f = mw.getCurrentFrame() |
||
− | end |
||
− | |||
− | -- Start table when appropriate |
||
− | local multirow = f:callParserFunction( '#dplvar', 'multirow' ) |
||
− | if multirow ~= '1' then |
||
− | 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 |
||
− | |||
− | -- End table when appropriate |
||
− | local foot = args.foot or '' |
||
− | if multirow then |
||
− | if foot ~= '' then |
||
− | 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 = 'Name !! ' |
||
− | f:callParserFunction( '#dplvar:set', 'craftingname', '1' ) |
||
− | end |
||
− | if args.showdescription == '1' then |
||
− | description = ' !! class="unsortable" | Description' |
||
− | f:callParserFunction( '#dplvar:set', 'craftingdescription', '1' ) |
||
− | end |
||
− | local class = args.class or '' |
||
− | local recipeClass = '' |
||
− | if multirow then |
||
− | class = 'sortable collapsible ' .. class |
||
− | recipeClass = 'class="unsortable" |' |
||
− | end |
||
− | header = table.concat( { |
||
− | ' {| class="wikitable ' .. class .. '" data-description="Ricette di fabbricazione"', |
||
− | '! ' .. name .. 'Ingredienti !! ' .. recipeClass .. ' Ricetta di [[fabbricazione]]' .. description, |
||
− | '|-' |
||
− | }, '\n' ) |
||
− | end |
||
− | |||
− | -- Name cell |
||
− | local nameCell |
||
− | if f:callParserFunction( '#dplvar', 'craftingname' ) == '1' then |
||
− | if args.name or '' ~= '' then |
||
− | nameCell = args.name |
||
− | else |
||
− | local names = {} |
||
− | local links = {} |
||
− | for v in mw.text.gsplit( args.Output or '', '%s*;%s*' ) do |
||
− | parts = getParts( v, args.Mod ) |
||
− | parts.mod = parts.mod or '' |
||
− | if not names[parts.mod .. ':' .. parts.name] then |
||
− | table.insert( links, prefixedLink( parts.name, parts.mod ) ) |
||
− | names[parts.mod .. ':' .. parts.name] = 1 |
||
− | end |
||
− | end |
||
− | |||
− | nameCell = table.concat( links, ' or<br>' ) |
||
− | end |
||
− | end |
||
− | |||
− | if nameCell and args.upcoming then |
||
− | nameCell = nameCell .. '<br>([[' .. args.upcoming .. ']])' |
||
− | end |
||
− | |||
− | -- Create ingredient list |
||
− | local ingredients = {} |
||
− | local ingredientKeys = {} |
||
− | local animatedIngredients = {} |
||
− | local animatedKeys = {} |
||
− | for k, v in pairs( args ) do |
||
− | v = mw.text.trim( v ) |
||
− | if v ~= '' and tostring( k ):find( '^%u?%d%d?$' ) then |
||
− | if v:find( ';' ) then |
||
− | table.insert( animatedKeys, v ) |
||
− | else |
||
− | local parts = getParts( v, args.Mod ) |
||
− | parts.mod = parts.mod or '' |
||
− | local fullName = parts.mod .. ':' .. parts.name |
||
− | if not ingredients[fullName] then |
||
− | table.insert( ingredientKeys, fullName ) |
||
− | ingredients[fullName] = { mod = parts.mod, name = parts.name } |
||
− | end |
||
− | end |
||
− | end |
||
− | end |
||
− | for k, v in ipairs( animatedKeys ) do |
||
− | local frames = mw.text.split( v, '%s*;%s*' ) |
||
− | local length = #frames |
||
− | for k2, v2 in ipairs( frames ) do |
||
− | local parts = getParts( v2, args.Mod ) |
||
− | parts.mod = parts.mod or '' |
||
− | local fullName = parts.mod .. ':' .. parts.name |
||
− | if v2 ~= '' and not ingredients[fullName] and not animatedIngredients[fullName] then |
||
− | table.insert( ingredientKeys, fullName ) |
||
− | animatedIngredients[fullName] = { mod = parts.mod, name = parts.name, final = k2 == length } |
||
− | end |
||
− | end |
||
− | end |
||
− | |||
− | -- Ingredients cell |
||
− | local ingredientsCell |
||
− | if args.ingredients or '' ~= '' then |
||
− | ingredientsCell = args.ingredients |
||
− | else |
||
− | ingredientsCell = {} |
||
− | for k, v in ipairs( ingredientKeys ) do |
||
− | local separator = ' +' |
||
− | if k == #ingredientKeys then |
||
− | separator = '' |
||
− | elseif animatedIngredients[v] and not animatedIngredients[v].final then |
||
− | separator = ' o' |
||
− | end |
||
− | |||
− | local mod = ( ingredients[v] or animatedIngredients[v] ).mod |
||
− | local name = ( ingredients[v] or animatedIngredients[v] ).name |
||
− | table.insert( ingredientsCell, prefixedLink( name, mod ) .. separator ) |
||
− | end |
||
− | |||
− | ingredientsCell = table.concat( ingredientsCell, '<br>\n' ) |
||
end |
end |
||
-- Automatic shapeless positioning |
-- Automatic shapeless positioning |
||
− | local newArgs = {} |
||
if args[1] then |
if args[1] then |
||
− | + | args.shapeless = 1 |
|
if args[7] then |
if args[7] then |
||
− | + | args.A1 = args[1] |
|
− | + | args.B1 = args[2] |
|
− | + | args.C1 = args[3] |
|
− | + | args.A2 = args[4] |
|
− | + | args.B2 = args[5] |
|
− | + | args.C2 = args[6] |
|
if args[8] then |
if args[8] then |
||
-- ◼◼◼ ◼◼◼ |
-- ◼◼◼ ◼◼◼ |
||
-- ◼◼◼ OR ◼◼◼ |
-- ◼◼◼ OR ◼◼◼ |
||
-- ◼◼◼ ◼◼◻ |
-- ◼◼◼ ◼◼◻ |
||
− | + | args.A3 = args[7] |
|
− | + | args.B3 = args[8] |
|
− | + | args.C3 = args[9] |
|
if args[9] then |
if args[9] then |
||
local identical = true |
local identical = true |
||
Riga 186: | Riga 71: | ||
if args[i] ~= args[i + 1] then |
if args[i] ~= args[i + 1] then |
||
identical = false |
identical = false |
||
+ | break |
||
end |
end |
||
end |
end |
||
if identical then |
if identical then |
||
− | + | args.shapeless = nil |
|
end |
end |
||
end |
end |
||
Riga 196: | Riga 82: | ||
-- ◼◼◼ |
-- ◼◼◼ |
||
-- ◻◼◻ |
-- ◻◼◻ |
||
− | + | args.B3 = args[7] |
|
end |
end |
||
elseif args[2] then |
elseif args[2] then |
||
− | + | args.A2 = args[1] |
|
− | + | args.B2 = args[2] |
|
if args[5] then |
if args[5] then |
||
-- ◻◻◻ ◻◻◻ |
-- ◻◻◻ ◻◻◻ |
||
-- ◼◼◼ OR ◼◼◼ |
-- ◼◼◼ OR ◼◼◼ |
||
-- ◼◼◼ ◼◼◻ |
-- ◼◼◼ ◼◼◻ |
||
− | + | args.C2 = args[3] |
|
− | + | args.A3 = args[4] |
|
− | + | args.B3 = args[5] |
|
− | + | args.C3 = args[6] |
|
elseif args[4] then |
elseif args[4] then |
||
-- ◻◻◻ |
-- ◻◻◻ |
||
-- ◼◼◻ |
-- ◼◼◻ |
||
-- ◼◼◻ |
-- ◼◼◻ |
||
− | + | args.A3 = args[3] |
|
− | + | args.B3 = args[4] |
|
else |
else |
||
-- ◻◻◻ ◻◻◻ |
-- ◻◻◻ ◻◻◻ |
||
-- ◼◼◻ OR ◼◼◻ |
-- ◼◼◻ OR ◼◼◻ |
||
-- ◻◼◻ ◻◻◻ |
-- ◻◼◻ ◻◻◻ |
||
− | + | args.B3 = args[3] |
|
end |
end |
||
else |
else |
||
Riga 225: | Riga 111: | ||
-- ◻◼◻ |
-- ◻◼◻ |
||
-- ◻◻◻ |
-- ◻◻◻ |
||
− | + | args.B2 = args[1] |
|
− | + | args.shapeless = nil |
|
+ | end |
||
+ | |||
+ | for i = 1, 9 do |
||
+ | args[i] = nil |
||
end |
end |
||
− | else |
||
− | newArgs.A1 = args.A1 |
||
− | newArgs.B1 = args.B1 |
||
− | newArgs.C1 = args.C1 |
||
− | newArgs.A2 = args.A2 |
||
− | newArgs.B2 = args.B2 |
||
− | newArgs.C2 = args.C2 |
||
− | newArgs.A3 = args.A3 |
||
− | newArgs.B3 = args.B3 |
||
− | newArgs.C3 = args.C3 |
||
− | newArgs.fixed = args.fixed |
||
− | newArgs.notfixed = args.notfixed |
||
end |
end |
||
− | -- |
+ | -- Create recipe table, and list of ingredients |
+ | local out, ingredientSets = recipeTable( args, { |
||
− | newArgs.Mod = args.Mod |
||
+ | uiFunc = 'craftingTable', |
||
− | newArgs.Output = args.Output |
||
+ | type = i18n.type, |
||
− | newArgs.Otitle = args.Otitle |
||
+ | ingredientArgs = cArgVals, |
||
− | newArgs.Olink = args.Olink |
||
+ | outputArgs = { 'Output' }, |
||
+ | } ) |
||
+ | local title = mw.title.getCurrentTitle() |
||
− | -- Recipe cell |
||
+ | if args.nocat == '1' or title.namespace ~= 0 or title.isSubpage then |
||
− | local recipeCell = require( 'Modulo:UI' ).craftingTable( newArgs ) |
||
+ | return out |
||
− | |||
− | local row = { |
||
− | '\n' .. ingredientsCell, |
||
− | 'style="padding:1px" |\n' .. recipeCell |
||
− | } |
||
− | if nameCell then |
||
− | table.insert( row, 1, nameCell ) |
||
end |
end |
||
− | if f:callParserFunction( '#dplvar', 'craftingdescription' ) == '1' then |
||
− | table.insert( row, args.description or '' ) |
||
− | end |
||
− | row = table.concat( row, '\n|' ) |
||
+ | local categories = {} |
||
− | if nameCell then |
||
+ | local cI = 1 |
||
− | row = '!\n' .. row |
||
+ | if args.upcoming then |
||
− | else |
||
+ | categories[cI] = '[[' .. i18n.categoryUpcoming .. ']]' |
||
− | row = '|\n' .. row |
||
+ | cI = cI + 1 |
||
end |
end |
||
+ | if args.type and args.ignoreusage ~= '1' then |
||
− | local footer = '' |
||
+ | categories[cI] = '[[' .. i18n.categoryRecipeType:gsub( '%$1', args.type ) .. ']]' |
||
− | if foot ~= '' then |
||
− | + | cI = cI + 1 |
|
− | f:callParserFunction( '#dplvar:set', 'craftingname', '0', 'craftingdescription', '0' ) |
||
end |
end |
||
+ | if args.ignoreusage ~= '1' then |
||
− | -- Create ingredient categories for DPL |
||
+ | -- Create ingredient categories for DPL |
||
− | local title = mw.title.getCurrentTitle() |
||
− | + | local usedNames = {} |
|
− | if args.nocat ~= '1' and title.namespace == 0 and not title.isSubpage then |
||
− | categories = {} |
||
+ | local function addName(name) |
||
− | if args.upcoming then |
||
+ | if not usedNames[name] then -- redundant with most current code, but not with all, and might prevent other issues |
||
− | table.insert( categories, '[[Categoria:In arrivo]]' ) |
||
+ | categories[cI] = '[[' .. i18n.categoryIngredientUsage:gsub( '%$1', name ) .. ']]' |
||
+ | cI = cI + 1 |
||
+ | usedNames[name] = true |
||
+ | end |
||
end |
end |
||
+ | |||
− | |||
+ | for _, ingredientSet in pairs( ingredientSets ) do |
||
− | if args.type then |
||
+ | for _, ingredient in pairs( ingredientSet ) do |
||
− | table.insert( categories, '[[Categoria:Ricetta di ' .. args.type .. ']]' ) |
||
+ | local name = ingredient.name |
||
− | end |
||
+ | if not ingredient.mod and not usedNames[name] and name ~= title.text then |
||
− | |||
+ | -- List each dye individually as they have their own pages |
||
− | if args.ignoreusage ~= '1' then |
||
+ | if |
||
− | local dyes = { |
||
+ | name == slot.i18n.prefixes.any .. ' ' .. i18n.itemDye or |
||
− | 'Colorante arancione', 'Colorante magenta', 'Colorante azzurro', 'Colorante giallo', 'Colorante lime', |
||
+ | name == slot.i18n.suffixes.matching .. ' ' .. i18n.itemDye or |
||
− | 'Colorante rosa', 'Colorante grigio', 'Colorante grigio chiaro', 'Colorante ciano', 'Colorante viola', |
||
+ | name == slot.i18n.prefixes.any .. ' ' .. i18n.itemColoredDye or |
||
− | 'Lapislazzuli', 'Cacao', 'Colorante verde', 'Colorante rosso', 'Sacca d\'inchiostro' |
||
+ | name == slot.i18n.suffixes.matching .. ' ' .. i18n.itemColoredDye |
||
− | } |
||
+ | then |
||
− | local variants = { |
||
+ | if not name:find( i18n.colored ) then |
||
− | 'Legno', 'Assi', 'Vetro colorato', 'Lastra di vetro clorato', 'Lana', |
||
+ | addName( i18n.itemWhiteDye ) |
||
− | 'Arenaria', 'Scalini', 'Lastra', 'Pedana a pressione', 'Stella pirotecnica', |
||
− | 'Pietre', 'Andesite', 'Diorite', 'Granito', 'Stendardo', 'Scudo' |
||
− | } |
||
− | |||
− | for k, v in ipairs( ingredientKeys ) do |
||
− | v = v:sub( 2 ) |
||
− | if not v:find( ':' ) then |
||
− | if v == 'Ogni colorante' then |
||
− | if v == 'Ogni colorante' then |
||
− | table.insert( dyes, 1, 'Farina d\'ossa' ) |
||
end |
end |
||
− | for _, dye in |
+ | for _, dye in pairs( i18n.coloredDyes ) do |
+ | addName( dye ) |
||
− | table.insert( categories, '[[Categoria:Ricetta che usa ' .. dye .. ']]' ) |
||
+ | end |
||
+ | -- List stone variants individually as they have their own pages |
||
+ | elseif |
||
+ | name == slot.i18n.prefixes.any .. ' ' .. i18n.itemStone or |
||
+ | name == slot.i18n.suffixes.matching .. ' ' .. i18n.itemStone |
||
+ | then |
||
+ | for _, stone in pairs( i18n.stoneVariants ) do |
||
+ | addName( stone ) |
||
end |
end |
||
else |
else |
||
− | + | -- Merge item variants which use a single page |
|
+ | if |
||
− | elseif v == 'Ogni fungo' or v == 'Fungo rosso' or v == 'Fungo marrone' then v = 'Fungo' |
||
+ | name == slot.i18n.prefixes.any .. ' ' .. i18n.itemMushroom or |
||
− | elseif v == 'Sabbia rossa' then v = 'Sabbia' |
||
+ | name == slot.i18n.suffixes.matching .. ' ' .. i18n.itemMushroom or |
||
− | elseif v == 'Carbonella' then v = 'Carbone' |
||
+ | name == i18n.itemRedMushroom or |
||
− | elseif v:find( 'Arenaria rossa$' ) then v = 'Arenaria rossa' |
||
+ | name == i18n.itemBrownMushroom |
||
− | elseif v:find( ' Blocco di quarzo$' ) then v = 'Blocco di quarzo' |
||
+ | then name = i18n.itemMushroom |
||
+ | elseif name == i18n.itemCharcoal then name = i18n.itemCoal |
||
+ | elseif name:find( ' ' .. i18n.itemQuartzBlock .. '$' ) then name = i18n.itemBlockOfQuartz |
||
else |
else |
||
− | + | for _, variant in pairs( i18n.variantPages ) do |
|
− | + | if name:find( ' ' .. variant .. '$' ) then |
|
− | + | name = variant |
|
− | v = variant |
||
break |
break |
||
end |
end |
||
Riga 329: | Riga 202: | ||
-- Remove prefixes |
-- Remove prefixes |
||
− | for _, prefix in pairs( prefixes ) do |
+ | for _, prefix in pairs( slot.i18n.prefixes ) do |
− | if |
+ | if name:find( '^' .. prefix .. ' ' ) then |
− | + | name = name:gsub( '^' .. prefix .. ' ', '' ) |
|
+ | break |
||
+ | end |
||
+ | end |
||
+ | |||
+ | -- Remove suffixes |
||
+ | for _, suffixSet in pairs( slot.i18n.suffixes ) do |
||
+ | local found |
||
+ | if type( suffixSet ) ~= 'table' then |
||
+ | suffixSet = { suffixSet } |
||
+ | end |
||
+ | for _, suffix in pairs( suffixSet ) do |
||
+ | if name:find( ' ' .. suffix .. '$' ) then |
||
+ | found = true |
||
+ | name = name:gsub( ' ' .. suffix .. '$', '' ) |
||
+ | break |
||
+ | end |
||
+ | end |
||
+ | if found then |
||
break |
break |
||
end |
end |
||
Riga 337: | Riga 228: | ||
end |
end |
||
+ | -- handle "A or B" names |
||
− | table.insert( categories, '[[Categoria:Ricetta che usa ' .. v .. ']]' ) |
||
+ | local orA, orB = name:match("(.-) or (.+)") |
||
+ | if orA then |
||
+ | addName( orA ) |
||
+ | addName( orB ) |
||
+ | else |
||
+ | addName( name ) |
||
+ | end |
||
end |
end |
||
end |
end |
||
end |
end |
||
end |
end |
||
− | |||
− | categories = table.concat( categories, '' ) |
||
end |
end |
||
+ | return out, table.concat( categories, '' ) |
||
− | if args.debug == '1' then |
||
− | return '<pre>' .. header .. '\n' .. row .. '\n|-\n' .. footer .. categories .. '</pre>' |
||
− | else |
||
− | return header .. '\n' .. row .. '\n|-\n' .. footer .. categories |
||
− | end |
||
end |
end |
||
+ | |||
return p |
return p |
Versione delle 10:22, 28 ott 2020
La documentazione per questo modulo può essere creata in Modulo:Fabbricazione/doc
local p = {}
local i18n = {
colored = 'Colorato',
coloredDyes = {
'Colorante arancione', 'Colorante magenta', 'Colorante azzurro', 'Colorante giallo', 'Colorante lime',
'Colorante rosa', 'Colorante grigio', 'Colorante grigio chiaro', 'Colorante ciano', 'Colorante viola',
'Colorante blu', 'Colorante marrone', 'Colorante verde',
'Colorante rosso', 'Colorante nero',
},
categoryIngredientUsage = 'Categoria:Ricetta che usa $1',
categoryRecipeType = 'Categoria:Ricetta di $1',
categoryUpcoming = 'Categoria:In arrivo',
itemBlockOfQuartz = 'Blocco di quarzo',
itemBrownMushroom = 'Fungo marrone',
itemCharcoal = 'Carbonella',
itemCoal = 'Carbone',
itemColoredDye = 'Colorante',
itemDye = 'Colorante',
itemMushroom = 'Fungo',
itemQuartzBlock = 'Blocco di quarzo',
itemRedMushroom = 'Fungo rosso',
itemStone = 'Pietra',
itemWhiteDye = 'Colorante bianco',
moduleArgs = [[Modulo:ProcessArgs]],
moduleRecipe = [[Modulo:Recipe table]],
moduleSlot = [[Modulo:Inventory slot]],
stoneVariants = { 'Pietra', 'Andesite', 'Granito', 'Diorite' },
type = 'Fabbricazione',
variantPages = {
'Andesite', 'Stendardo', 'Letto', 'Diorite', 'Stella pirotecnica', 'Granito',
'Pedana a pressione', 'Sabbia', 'Arenaria', 'Scudo', 'Lastra', 'Pannello di vetro',
'Vetro', 'Scalini', 'Mattoni di pietra', 'Assi di legno', 'Legno', 'Lana',
},
}
p.i18n = i18n
local slot = require( i18n.moduleSlot )
local recipeTable = require( i18n.moduleRecipe ).table
local cArgVals = { 'A1', 'B1', 'C1', 'A2', 'B2', 'C2', 'A3', 'B3', 'C3' }
p.cArgVals = cArgVals
function p.table( f )
local args = f
if f == mw.getCurrentFrame() then
args = require( i18n.moduleArgs ).merge( true )
else
f = mw.getCurrentFrame()
end
-- Automatic shapeless positioning
if args[1] then
args.shapeless = 1
if args[7] then
args.A1 = args[1]
args.B1 = args[2]
args.C1 = args[3]
args.A2 = args[4]
args.B2 = args[5]
args.C2 = args[6]
if args[8] then
-- ◼◼◼ ◼◼◼
-- ◼◼◼ OR ◼◼◼
-- ◼◼◼ ◼◼◻
args.A3 = args[7]
args.B3 = args[8]
args.C3 = args[9]
if args[9] then
local identical = true
for i = 1, 8 do
if args[i] ~= args[i + 1] then
identical = false
break
end
end
if identical then
args.shapeless = nil
end
end
else
-- ◼◼◼
-- ◼◼◼
-- ◻◼◻
args.B3 = args[7]
end
elseif args[2] then
args.A2 = args[1]
args.B2 = args[2]
if args[5] then
-- ◻◻◻ ◻◻◻
-- ◼◼◼ OR ◼◼◼
-- ◼◼◼ ◼◼◻
args.C2 = args[3]
args.A3 = args[4]
args.B3 = args[5]
args.C3 = args[6]
elseif args[4] then
-- ◻◻◻
-- ◼◼◻
-- ◼◼◻
args.A3 = args[3]
args.B3 = args[4]
else
-- ◻◻◻ ◻◻◻
-- ◼◼◻ OR ◼◼◻
-- ◻◼◻ ◻◻◻
args.B3 = args[3]
end
else
-- ◻◻◻
-- ◻◼◻
-- ◻◻◻
args.B2 = args[1]
args.shapeless = nil
end
for i = 1, 9 do
args[i] = nil
end
end
-- Create recipe table, and list of ingredients
local out, ingredientSets = recipeTable( args, {
uiFunc = 'craftingTable',
type = i18n.type,
ingredientArgs = cArgVals,
outputArgs = { 'Output' },
} )
local title = mw.title.getCurrentTitle()
if args.nocat == '1' or title.namespace ~= 0 or title.isSubpage then
return out
end
local categories = {}
local cI = 1
if args.upcoming then
categories[cI] = '[[' .. i18n.categoryUpcoming .. ']]'
cI = cI + 1
end
if args.type and args.ignoreusage ~= '1' then
categories[cI] = '[[' .. i18n.categoryRecipeType:gsub( '%$1', args.type ) .. ']]'
cI = cI + 1
end
if args.ignoreusage ~= '1' then
-- Create ingredient categories for DPL
local usedNames = {}
local function addName(name)
if not usedNames[name] then -- redundant with most current code, but not with all, and might prevent other issues
categories[cI] = '[[' .. i18n.categoryIngredientUsage:gsub( '%$1', name ) .. ']]'
cI = cI + 1
usedNames[name] = true
end
end
for _, ingredientSet in pairs( ingredientSets ) do
for _, ingredient in pairs( ingredientSet ) do
local name = ingredient.name
if not ingredient.mod and not usedNames[name] and name ~= title.text then
-- List each dye individually as they have their own pages
if
name == slot.i18n.prefixes.any .. ' ' .. i18n.itemDye or
name == slot.i18n.suffixes.matching .. ' ' .. i18n.itemDye or
name == slot.i18n.prefixes.any .. ' ' .. i18n.itemColoredDye or
name == slot.i18n.suffixes.matching .. ' ' .. i18n.itemColoredDye
then
if not name:find( i18n.colored ) then
addName( i18n.itemWhiteDye )
end
for _, dye in pairs( i18n.coloredDyes ) do
addName( dye )
end
-- List stone variants individually as they have their own pages
elseif
name == slot.i18n.prefixes.any .. ' ' .. i18n.itemStone or
name == slot.i18n.suffixes.matching .. ' ' .. i18n.itemStone
then
for _, stone in pairs( i18n.stoneVariants ) do
addName( stone )
end
else
-- Merge item variants which use a single page
if
name == slot.i18n.prefixes.any .. ' ' .. i18n.itemMushroom or
name == slot.i18n.suffixes.matching .. ' ' .. i18n.itemMushroom or
name == i18n.itemRedMushroom or
name == i18n.itemBrownMushroom
then name = i18n.itemMushroom
elseif name == i18n.itemCharcoal then name = i18n.itemCoal
elseif name:find( ' ' .. i18n.itemQuartzBlock .. '$' ) then name = i18n.itemBlockOfQuartz
else
for _, variant in pairs( i18n.variantPages ) do
if name:find( ' ' .. variant .. '$' ) then
name = variant
break
end
end
-- Remove prefixes
for _, prefix in pairs( slot.i18n.prefixes ) do
if name:find( '^' .. prefix .. ' ' ) then
name = name:gsub( '^' .. prefix .. ' ', '' )
break
end
end
-- Remove suffixes
for _, suffixSet in pairs( slot.i18n.suffixes ) do
local found
if type( suffixSet ) ~= 'table' then
suffixSet = { suffixSet }
end
for _, suffix in pairs( suffixSet ) do
if name:find( ' ' .. suffix .. '$' ) then
found = true
name = name:gsub( ' ' .. suffix .. '$', '' )
break
end
end
if found then
break
end
end
end
-- handle "A or B" names
local orA, orB = name:match("(.-) or (.+)")
if orA then
addName( orA )
addName( orB )
else
addName( name )
end
end
end
end
end
end
return out, table.concat( categories, '' )
end
return p