Minecraft Wiki
(Se ha deshecho la revisión 124421 de Roirosal (disc.))
Etiqueta: Deshacer
mSin resumen de edición
 
(No se muestran 13 ediciones intermedias de 3 usuarios)
Línea 4: Línea 4:
 
colored = 'Colored',
 
colored = 'Colored',
 
coloredDyes = {
 
coloredDyes = {
'Orange Dye', 'Magenta Dye', 'Light Blue Dye', 'Yellow Dye', 'Lime Dye',
+
'Tinte naranja', 'Tinte magenta', 'Tinte azul claro', 'Tinte amarillo', 'Tinte verde lima',
'Pink Dye', 'Gray Dye', 'Light Gray Dye', 'Cyan Dye', 'Purple Dye',
+
'Tinte rosa', 'Tinte gris', 'Tinte gris claro', 'Tinte cian', 'Tinte morado',
'Blue Dye', 'Brown Dye', 'Green Dye',
+
'Tinte azul', 'Tinte marrón', 'Tinte verde',
'Red Dye', 'Black Dye',
+
'Tinte rojo', 'Tinte negro',
 
},
 
},
categoryIngredientUsage = 'Category:Recipe using $1',
+
categoryIngredientUsage = 'Categoría:Receta usando $1',
categoryRecipeType = 'Category:$1 recipe',
+
categoryRecipeType = 'Categoría:Receta de $1',
categoryUpcoming = 'Category:Upcoming',
+
categoryUpcoming = 'Categoría:Próximamante',
itemBlockOfQuartz = 'Block of Quartz',
+
itemBlockOfQuartz = 'Bloque de cuarzo',
itemBrownMushroom = 'Brown Mushroom',
+
itemBrownMushroom = 'Champiñón marrón',
itemCharcoal = 'Charcoal',
+
itemCharcoal = 'Carbón vegetal',
 
itemCoal = 'Carbón',
 
itemCoal = 'Carbón',
itemColoredDye = 'Colored Dye',
+
itemColoredDye = 'Tinte de color',
itemDye = 'Dye',
+
itemDye = 'Tinte',
 
itemMushroom = 'Champiñón',
 
itemMushroom = 'Champiñón',
itemQuartzBlock = 'Quartz Block',
+
itemQuartzBlock = 'Bloque de cuarzo',
itemRedMushroom = 'Red Mushroom',
+
itemRedMushroom = 'Champiñón rojo',
itemStone = 'Stone',
+
itemStone = 'Piedra',
itemWhiteDye = 'White Dye',
+
itemWhiteDye = 'Tinte blanco',
moduleArgs = [[Module:ProcessArgs]],
+
moduleArgs = [[Módulo:ProcessArgs]],
moduleRecipe = [[Module:Recipe table]],
+
moduleRecipe = [[Módulo:Recipe table]],
moduleSlot = [[Module:Inventory slot]],
+
moduleSlot = [[Módulo:Inventory slot]],
stoneVariants = { 'Stone', 'Andesite', 'Granite', 'Diorite' },
+
stoneVariants = { 'Piedra', 'Andesita', 'Granito', 'Diorita' },
type = 'Crafting',
+
type = 'fabricación',
 
variantPages = {
 
variantPages = {
'Andesite', 'Banner', 'Bed', 'Diorite', 'Firework Star', 'Granite',
+
'Andesita', 'Estandarte', 'Cama', 'Diorita', 'Firework Star', 'Granito',
'Pressure Plate', 'Sand', 'Sandstone', 'Shield', 'Slab', 'Stained Glass Pane',
+
'Placa de presión', 'Arena', 'Arenisca', 'Escudo', 'Losa', 'Stained Glass Pane',
'Stained Glass', 'Stairs', 'Stone Bricks', 'Wood Planks', 'Wood', 'Wool',
+
'Cristal tintado', 'Escaleras', 'Stone Bricks', 'Wood Planks', 'Madera', 'Lana',
 
},
 
},
  +
CopperBlockLinks = {
  +
'Block of Copper', 'Exposed Copper', 'Weathered Copper', 'Oxidized Copper', 'Cut Copper', 'Exposed Cut Copper', 'Weathered Cut Copper', 'Oxidized Cut Copper', 'Waxed Block of Copper', 'Waxed Copper', 'Waxed Exposed Copper', 'Waxed Weathered Copper', 'Waxed Cut Copper', 'Waxed Exposed Cut Copper', 'Waxed Weathered Cut Copper', 'Copper Block'
  +
},
  +
CopperBlock = 'Block of Copper',
 
}
 
}
 
p.i18n = i18n
 
p.i18n = i18n
Línea 61: Línea 65:
 
if args[8] then
 
if args[8] then
 
-- ◼◼◼ ◼◼◼
 
-- ◼◼◼ ◼◼◼
-- ◼◼◼ O ◼◼◼
+
-- ◼◼◼ OR ◼◼◼
 
-- ◼◼◼ ◼◼◻
 
-- ◼◼◼ ◼◼◻
 
args.A3 = args[7]
 
args.A3 = args[7]
Línea 89: Línea 93:
 
if args[5] then
 
if args[5] then
 
-- ◻◻◻ ◻◻◻
 
-- ◻◻◻ ◻◻◻
-- ◼◼◼ O ◼◼◼
+
-- ◼◼◼ OR ◼◼◼
 
-- ◼◼◼ ◼◼◻
 
-- ◼◼◼ ◼◼◻
 
args.C2 = args[3]
 
args.C2 = args[3]
Línea 103: Línea 107:
 
else
 
else
 
-- ◻◻◻ ◻◻◻
 
-- ◻◻◻ ◻◻◻
-- ◼◼◻ O ◼◼◻
+
-- ◼◼◻ OR ◼◼◻
 
-- ◻◼◻ ◻◻◻
 
-- ◻◼◻ ◻◻◻
 
args.B3 = args[3]
 
args.B3 = args[3]
Línea 135: Línea 139:
 
local categories = {}
 
local categories = {}
 
local cI = 1
 
local cI = 1
if args.upcoming then
 
categories[cI] = '[[' .. i18n.categoryUpcoming .. ']]'
 
cI = cI + 1
 
end
 
 
 
if args.type then
+
if args.type and args.ignoreusage ~= '1' then
 
categories[cI] = '[[' .. i18n.categoryRecipeType:gsub( '%$1', args.type ) .. ']]'
 
categories[cI] = '[[' .. i18n.categoryRecipeType:gsub( '%$1', args.type ) .. ']]'
 
cI = cI + 1
 
cI = cI + 1
Línea 148: Línea 148:
 
-- Create ingredient categories for DPL
 
-- Create ingredient categories for DPL
 
local usedNames = {}
 
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 _, ingredientSet in pairs( ingredientSets ) do
 
for _, ingredient in pairs( ingredientSet ) do
 
for _, ingredient in pairs( ingredientSet ) do
 
local name = ingredient.name
 
local name = ingredient.name
if not ingredient.mod and not usedNames[name] and name ~= title.text then
+
if not ingredient.mod and not usedNames[name] then
 
-- List each dye individually as they have their own pages
 
-- List each dye individually as they have their own pages
 
if
 
if
Línea 160: Línea 169:
 
then
 
then
 
if not name:find( i18n.colored ) then
 
if not name:find( i18n.colored ) then
categories[cI] = '[[' .. i18n.categoryIngredientUsage:gsub( '%$1', i18n.itemWhiteDye ) .. ']]'
+
addName( i18n.itemWhiteDye )
cI = cI + 1
 
usedNames[i18n.itemWhiteDye] = true
 
 
end
 
end
 
 
 
for _, dye in pairs( i18n.coloredDyes ) do
 
for _, dye in pairs( i18n.coloredDyes ) do
  +
addName( dye )
categories[cI] = '[[' .. i18n.categoryIngredientUsage:gsub( '%$1', dye ) .. ']]'
 
cI = cI + 1
 
usedNames[dye] = true
 
 
end
 
end
 
-- List stone variants individually as they have their own pages
 
-- List stone variants individually as they have their own pages
Línea 176: Línea 181:
 
then
 
then
 
for _, stone in pairs( i18n.stoneVariants ) do
 
for _, stone in pairs( i18n.stoneVariants ) do
 
addName( stone )
categories[cI] = '[[' .. i18n.categoryIngredientUsage:gsub( '%$1', stone ) .. ']]'
 
cI = cI + 1
 
usedNames[stone] = true
 
 
end
 
end
 
else
 
else
Línea 188: Línea 191:
 
name == i18n.itemBrownMushroom
 
name == i18n.itemBrownMushroom
 
then name = i18n.itemMushroom
 
then name = i18n.itemMushroom
  +
elseif name == i18n.itemSmoothQuartzBlock then name = i18n.itemSmoothQuartzBlock
 
elseif name == i18n.itemCharcoal then name = i18n.itemCoal
 
elseif name == i18n.itemCharcoal then name = i18n.itemCoal
 
elseif name:find( ' ' .. i18n.itemQuartzBlock .. '$' ) then name = i18n.itemBlockOfQuartz
 
elseif name:find( ' ' .. i18n.itemQuartzBlock .. '$' ) then name = i18n.itemBlockOfQuartz
Línea 197: Línea 201:
 
end
 
end
 
end
 
end
  +
for _, variant in pairs( i18n.CopperBlockLinks ) do
 
  +
if name:find( variant ) then
  +
name = i18n.CopperBlock
  +
break
  +
end
 
end
 
-- Remove prefixes
 
-- Remove prefixes
 
for _, prefix in pairs( slot.i18n.prefixes ) do
 
for _, prefix in pairs( slot.i18n.prefixes ) do
Línea 207: Línea 216:
 
end
 
end
 
 
if not usedNames[name] then
+
-- handle "A or B" names
  +
local orA, orB = name:match("(.-) or (.+)")
categories[cI] = '[[' .. i18n.categoryIngredientUsage:gsub( '%$1', name ) .. ']]'
 
cI = cI + 1
+
if orA then
usedNames[name] = true
+
addName( orA )
  +
addName( orB )
  +
else
  +
addName( name )
 
end
 
end
 
end
 
end

Revisión actual - 04:52 22 abr 2023

[Ver | Editar | Purgar]DocumentaciónVer código ↴

This module implements {{Fabricación}}.

Parent arguments are automatically merged with directly passed arguments (the latter overwriting the former).

Dependencies

[Ver | Editar | Purgar]La documentación arriba es transcluída desde Módulo:Fabricación/doc.
local p = {}

local i18n = {
	colored = 'Colored',
	coloredDyes = {
		'Tinte naranja', 'Tinte magenta', 'Tinte azul claro', 'Tinte amarillo', 'Tinte verde lima',
		'Tinte rosa', 'Tinte gris', 'Tinte gris claro', 'Tinte cian', 'Tinte morado',
		'Tinte azul', 'Tinte marrón', 'Tinte verde',
		'Tinte rojo', 'Tinte negro',
	},
	categoryIngredientUsage = 'Categoría:Receta usando $1',
	categoryRecipeType = 'Categoría:Receta de $1',
	categoryUpcoming = 'Categoría:Próximamante',
	itemBlockOfQuartz = 'Bloque de cuarzo',
	itemBrownMushroom = 'Champiñón marrón',
	itemCharcoal = 'Carbón vegetal',
	itemCoal = 'Carbón',
	itemColoredDye = 'Tinte de color',
	itemDye = 'Tinte',
	itemMushroom = 'Champiñón',
	itemQuartzBlock = 'Bloque de cuarzo',
	itemRedMushroom = 'Champiñón rojo',
	itemStone = 'Piedra',
	itemWhiteDye = 'Tinte blanco',
	moduleArgs = [[Módulo:ProcessArgs]],
	moduleRecipe = [[Módulo:Recipe table]],
	moduleSlot = [[Módulo:Inventory slot]],
	stoneVariants = { 'Piedra', 'Andesita', 'Granito', 'Diorita' },
	type = 'fabricación',
	variantPages = {
		'Andesita', 'Estandarte', 'Cama', 'Diorita', 'Firework Star', 'Granito', 
		'Placa de presión', 'Arena', 'Arenisca', 'Escudo', 'Losa', 'Stained Glass Pane', 
		'Cristal tintado', 'Escaleras', 'Stone Bricks', 'Wood Planks', 'Madera', 'Lana',
	},
    CopperBlockLinks = {
		'Block of Copper', 'Exposed Copper', 'Weathered Copper', 'Oxidized Copper', 'Cut Copper', 'Exposed Cut Copper', 'Weathered Cut Copper', 'Oxidized Cut Copper', 'Waxed Block of Copper', 'Waxed Copper', 'Waxed Exposed Copper', 'Waxed Weathered Copper', 'Waxed Cut Copper', 'Waxed Exposed Cut Copper', 'Waxed Weathered Cut Copper', 'Copper Block'
	},
    CopperBlock = 'Block of Copper',
}
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.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] then
					-- List each dye individually as they have their own pages
					if
						name == slot.i18n.prefixes.any .. ' ' .. i18n.itemDye or
						name == slot.i18n.prefixes.matching .. ' ' .. i18n.itemDye or
						name == slot.i18n.prefixes.any .. ' ' .. i18n.itemColoredDye or
						name == slot.i18n.prefixes.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.prefixes.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.prefixes.matching .. ' ' .. i18n.itemMushroom or
							name == i18n.itemRedMushroom or
							name == i18n.itemBrownMushroom
						then name = i18n.itemMushroom
						elseif name == i18n.itemSmoothQuartzBlock then name = i18n.itemSmoothQuartzBlock
						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
							for _, variant in pairs( i18n.CopperBlockLinks ) do
								if name:find( variant ) then
									name = i18n.CopperBlock
									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
						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