Diferencia entre revisiones de «Módulo:Crafting»

Leynaf (discusión | contribs.)
Sin resumen de edición
Leynaf (discusión | contribs.)
Sin resumen de edición
 
Línea 273: Línea 273:
if v == 'Tintes' then
if v == 'Tintes' then
for _, tinte in ipairs( {
for _, tinte in ipairs( {
'Tinte Naranja', 'Tinte Magenta', 'Tinte Azul Claro', 'Tinte Amarillo', 'Tinte Verde Lima',
'Tinte naranja', 'Tinte magenta', 'Tinte azul claro', 'Tinte amarillo', 'Tinte verde lima',
'Tinte Rosa', 'Tinte Gris', 'Tinte Gris Claro', 'Tinte Cian', 'Tinte Morado',
'Tinte rosa', 'Tinte gris', 'Tinte gris claro', 'Tinte cian', 'Tinte morado',
'Lapislázuli', 'Semillas de Cacao', 'Tinte Verde', 'Tinte Rojo', 'Saco de Tinta'
'Lapislázuli', 'Semillas de cacao', 'Tinte verde', 'Tinte rojo', 'Saco de tinta'
} ) do
} ) do
table.insert( categories, '[[Categoría:Recetas que usan ' .. tinte .. ']]' )
table.insert( categories, '[[Categoría:Recetas que usan ' .. tinte .. ']]' )
end
end
else
else
if v == 'Pistón Adhesivo' then v = 'Pistón'
if v == 'Pistón adhesivo' then v = 'Pistón'
                        elseif v == 'Champiñón rojo' or v == 'Champiñón marrón' then v = 'Champiñón'
elseif v == 'Champiñón Rojo' or v == 'Champiñón Marrón' then v = 'Champiñón'
elseif v == 'Champiñón Rojo' or v == 'Champiñón Marrón' then v = 'Champiñón'
                        elseif v == 'Champiñón rojo' or v == 'Champiñón marrón' then v = 'Champiñón'
elseif v == 'Arena Rojiza' then v = 'Arena'
elseif v == 'Arena Rojiza' then v = 'Arena'
                         elseif v == 'Arena roja' then v = 'Arena'
                         elseif v == 'Arena roja' then v = 'Arena'
                        elseif v == 'Carbón vegetal' then v = 'Carbón'
elseif v == 'Carbón Vegetal' then v = 'Carbón'
elseif v == 'Carbón Vegetal' then v = 'Carbón'
elseif v:find( ' Tronco de madera$' ) then v = 'Madera'
elseif v:find( ' Tronco de Madera$' ) then v = 'Madera'
elseif v:find( ' Tronco de Madera$' ) then v = 'Madera'
elseif v:find( ' Tablas de madera$' ) then v = 'Tablas de madera'
elseif v:find( ' Tablas de Madera$' ) then v = 'Tablas de Madera'
elseif v:find( ' Tablas de Madera$' ) then v = 'Tablas de Madera'
                         elseif v:find( ' Materiales$' ) then v = 'Materiales para Herramientas'
                         elseif v:find( ' Materiales$' ) then v = 'Materiales para herramientas'
elseif v:find( ' Cristal tintado$' ) then v = 'Cristal tintado'
elseif v:find( ' Cristal Tintado$' ) then v = 'Cristal Tintado'
elseif v:find( ' Cristal Tintado$' ) then v = 'Cristal Tintado'
elseif v:find( ' Panel de cristal tintado$' ) then v = 'Panel de cristal tintado'
elseif v:find( ' Panel de Cristal Tintado$' ) then v = 'Panel de Cristal Tintado'
elseif v:find( ' Panel de Cristal Tintado$' ) then v = 'Panel de Cristal Tintado'
elseif v:find( ' Lana$' ) then v = 'Lana'
elseif v:find( ' Lana$' ) then v = 'Lana'
elseif v:find( ' Arenisca$' ) then v = 'Arenisca'
elseif v:find( ' Arenisca$' ) then v = 'Arenisca'
elseif v:find( ' Escaleras de madera$' ) then v = 'Escaleras'
elseif v:find( ' Escaleras de Madera$' ) then v = 'Escaleras'
elseif v:find( ' Escaleras de Madera$' ) then v = 'Escaleras'
elseif v:find( ' Losa de madera$' ) then v = 'Losas'
elseif v:find( ' Losa de Madera$' ) then v = 'Losas'
elseif v:find( ' Losa de Madera$' ) then v = 'Losas'
elseif v:find( ' Placa de presión$' ) then v = 'Placa de presión'
elseif v:find( ' Placa de Presión$' ) then v = 'Placa de Presión'
elseif v:find( ' Placa de Presión$' ) then v = 'Placa de Presión'
elseif v:find( ' Tulipán$' ) then v = 'Tulipán'
elseif v:find( ' Tulipán$' ) then v = 'Tulipán'
elseif v:find( ' Estrella de fuegos artificiales$' ) then v = 'Estrella de fuegos artificiales'
elseif v:find( ' Estrella de Fuegos Artificiales$' ) then v = 'Estrella de Fuegos Artificiales'
elseif v:find( ' Estrella de Fuegos Artificiales$' ) then v = 'Estrella de Fuegos Artificiales'
elseif v:find( ' Ladrillos de piedra$' ) then v = 'Ladrillos de piedra'
elseif v:find( ' Ladrillos de Piedra$' ) then v = 'Ladrillos de Piedra'
elseif v:find( ' Ladrillos de Piedra$' ) then v = 'Ladrillos de Piedra'
elseif v:find( ' Bloques de cuarzo$' ) then v = 'Bloque de cuarzo'
elseif v:find( ' Bloques de Cuarzo$' ) then v = 'Bloque de Cuarzo'
elseif v:find( ' Bloques de Cuarzo$' ) then v = 'Bloque de Cuarzo'
elseif v:find( ' Andesita$' ) then v = 'Andesite'
elseif v:find( ' Andesita$' ) then v = 'Andesite'

Revisión actual - 21:13 9 abr 2015

local p = {} function p.table( f ) local args = f if f == mw.getCurrentFrame() then args = require( 'Module:ProcessArgs' ).merge() else f = mw.getCurrentFrame() end local grid = require( 'Module:Grid' )

-- 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 = 'Nombre !! ' f:callParserFunction( '#dplvar:set', 'craftingname', '1' ) end if args.showdescription == '1' then description = ' !! class="unsortable" | Descripción' f:callParserFunction( '#dplvar:set', 'craftingdescription', '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 .. 'Ingredientes !! ' .. recipeClass .. ' Receta de fabricación' .. 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 = grid.getParts( v, args.Mod ) parts.mod = parts.mod or if not names[parts.mod .. ':' .. parts.name] then local link = if parts.mod ~= then link = 'Mods/' .. parts.mod .. '/' .. parts.name .. '|' end

if parts.name:find( '^Any ' ) then table.insert( links, 'Any ' .. link .. parts.name:sub( 4 ) .. '' ) else table.insert( links, '' .. link .. parts.name .. '' ) end names[parts.mod .. ':' .. parts.name] = 1 end end

nameCell = table.concat( links, ' o
' ) end end

if nameCell and args.upcoming then nameCell = nameCell .. '
(' .. 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 = grid.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 = grid.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 link = 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 if mod ~= then link = 'Mods/'.. mod .. '/' .. name .. '|' end

if name:find( '^Any ' ) then table.insert( ingredientsCell, 'Any ' .. link .. name:sub( 5 ) .. '' .. separator ) else table.insert( ingredientsCell, '' .. link .. name .. '' .. separator ) end end

ingredientsCell = table.concat( ingredientsCell, '
\n' ) end

-- Automatic shapeless positioning local newArgs = {} if args[1] then newArgs.shapeless = 1 if args[7] then newArgs.A1 = args[1] newArgs.B1 = args[2] newArgs.C1 = args[3] newArgs.A2 = args[4] newArgs.B2 = args[5] newArgs.C2 = args[6] if args[8] then -- ◼◼◼ ◼◼◼ -- ◼◼◼ OR ◼◼◼ -- ◼◼◼ ◼◼◻ newArgs.A3 = args[7] newArgs.B3 = args[8] newArgs.C3 = args[9] else -- ◼◼◼ -- ◼◼◼ -- ◻◼◻ newArgs.B3 = args[7] end elseif args[2] then newArgs.A2 = args[1] newArgs.B2 = args[2] if args[5] then -- ◻◻◻ ◻◻◻ -- ◼◼◼ OR ◼◼◼ -- ◼◼◼ ◼◼◻ newArgs.C2 = args[3] newArgs.A3 = args[4] newArgs.B3 = args[5] newArgs.C3 = args[6] elseif args[4] then -- ◻◻◻ -- ◼◼◻ -- ◼◼◻ newArgs.A3 = args[3] newArgs.B3 = args[4] else -- ◻◻◻ ◻◻◻ -- ◼◼◻ OR ◼◼◻ -- ◻◼◻ ◻◻◻ newArgs.B3 = args[3] end else -- ◻◻◻ -- ◻◼◻ -- ◻◻◻ newArgs.B2 = args[1] 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 end

-- Any other args we want to pass along newArgs.Mod = args.Mod newArgs.Output = args.Output newArgs.Otitle = args.Otitle

-- Recipe cell local recipeCell = grid.craftingTable( newArgs )

local row = { ingredientsCell, recipeCell } if nameCell then table.insert( row, 1, nameCell ) end if ( args.description or ) ~= and f:callParserFunction( '#dplvar', 'craftingdescription' ) == '1' then table.insert( row, args.description ) 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', 'craftingname', '0', 'craftingdescription', '0' ) end

-- Create ingredient categories for DPL local title = mw.title.getCurrentTitle() local categories = if args.nocat ~= '1' and title.namespace == 0 and not title.isSubpage then categories = {}

if args.upcoming then table.insert( categories, ) end

       if args.type then
           table.insert( categories,  )	
       end

if args.ignoreusage ~= '1' then for k, v in ipairs( ingredientKeys ) do v = v:sub( 2 ) if not v:find( ':' ) then if v == 'Tintes' then for _, tinte in ipairs( { 'Tinte naranja', 'Tinte magenta', 'Tinte azul claro', 'Tinte amarillo', 'Tinte verde lima', 'Tinte rosa', 'Tinte gris', 'Tinte gris claro', 'Tinte cian', 'Tinte morado', 'Lapislázuli', 'Semillas de cacao', 'Tinte verde', 'Tinte rojo', 'Saco de tinta' } ) do table.insert( categories, ) end else if v == 'Pistón adhesivo' then v = 'Pistón'

                       elseif v == 'Champiñón rojo' or v == 'Champiñón marrón' then v = 'Champiñón'

elseif v == 'Champiñón Rojo' or v == 'Champiñón Marrón' then v = 'Champiñón' elseif v == 'Arena Rojiza' then v = 'Arena'

                       elseif v == 'Arena roja' then v = 'Arena'
                       elseif v == 'Carbón vegetal' then v = 'Carbón'

elseif v == 'Carbón Vegetal' then v = 'Carbón' elseif v:find( ' Tronco de madera$' ) then v = 'Madera' elseif v:find( ' Tronco de Madera$' ) then v = 'Madera' elseif v:find( ' Tablas de madera$' ) then v = 'Tablas de madera' elseif v:find( ' Tablas de Madera$' ) then v = 'Tablas de Madera'

                       elseif v:find( ' Materiales$' ) then v = 'Materiales para herramientas'

elseif v:find( ' Cristal tintado$' ) then v = 'Cristal tintado' elseif v:find( ' Cristal Tintado$' ) then v = 'Cristal Tintado' elseif v:find( ' Panel de cristal tintado$' ) then v = 'Panel de cristal tintado' elseif v:find( ' Panel de Cristal Tintado$' ) then v = 'Panel de Cristal Tintado' elseif v:find( ' Lana$' ) then v = 'Lana' elseif v:find( ' Arenisca$' ) then v = 'Arenisca' elseif v:find( ' Escaleras de madera$' ) then v = 'Escaleras' elseif v:find( ' Escaleras de Madera$' ) then v = 'Escaleras' elseif v:find( ' Losa de madera$' ) then v = 'Losas' elseif v:find( ' Losa de Madera$' ) then v = 'Losas' elseif v:find( ' Placa de presión$' ) then v = 'Placa de presión' elseif v:find( ' Placa de Presión$' ) then v = 'Placa de Presión' elseif v:find( ' Tulipán$' ) then v = 'Tulipán' elseif v:find( ' Estrella de fuegos artificiales$' ) then v = 'Estrella de fuegos artificiales' elseif v:find( ' Estrella de Fuegos Artificiales$' ) then v = 'Estrella de Fuegos Artificiales' elseif v:find( ' Ladrillos de piedra$' ) then v = 'Ladrillos de piedra' elseif v:find( ' Ladrillos de Piedra$' ) then v = 'Ladrillos de Piedra' elseif v:find( ' Bloques de cuarzo$' ) then v = 'Bloque de cuarzo' elseif v:find( ' Bloques de Cuarzo$' ) then v = 'Bloque de Cuarzo' elseif v:find( ' Andesita$' ) then v = 'Andesite' elseif v:find( ' Diorita$' ) then v = 'Diorite' elseif v:find( ' Granito$' ) then v = 'Granite' end

table.insert( categories, ) end end end end

categories = table.concat( categories, ) end

if args.debug == '1' then

return '

' .. header .. '\n' .. row .. '\n|-\n' .. footer .. categories .. '

'

else return header .. '\n' .. row .. '\n|-\n' .. footer .. categories end end return p