Minecraft Wiki
Sem resumo de edição
Sem resumo de edição
 
(5 revisões intermediárias por 3 usuários não estão sendo mostradas)
Linha 4: Linha 4:
 
colored = 'Colorido',
 
colored = 'Colorido',
 
coloredDyes = {
 
coloredDyes = {
'Corante Laranja', 'Corante Magenta', 'Corante Azul Claro', 'Amarelo do Dente-de-Leão', 'Corante Verde Limão',
+
'Corante laranja', 'Corante magenta', 'Corante azul-claro', 'Corante amarelo', 'Corante verde-limão',
'Corante Rosa', 'Corante Cinza', 'Corante Cinza Claro', 'Corante Ciano', 'Corante Lilás',
+
'Corante rosa', 'Corante cinza', 'Corante cinza-claro', 'Corante ciano', 'Corante roxo',
'Lápis-Lazúli', 'Sementes de Cacau', 'Verde do Cacto', 'Vermelho da Rosa', 'Bolsa de Tinta',
+
'Corante azul', 'Corante marrom', 'Corante verde', 'Corante vermelho', 'Corante preto',
 
},
 
},
 
categoryIngredientUsage = 'Categoria:Receita usando $1',
 
categoryIngredientUsage = 'Categoria:Receita usando $1',
 
categoryRecipeType = 'Categoria:Receita de $1',
 
categoryRecipeType = 'Categoria:Receita de $1',
 
categoryUpcoming = 'Categoria:Em breve',
 
categoryUpcoming = 'Categoria:Em breve',
itemBlockOfQuartz = 'Bloco de Quartzo',
+
itemBlockOfQuartz = 'Bloco de quartzo',
itemBoneMeal = 'Farinha de Osso',
+
itemBoneMeal = 'Farinha de osso',
itemBrownMushroom = 'Cogumelo Marrom',
+
itemBrownMushroom = 'Cogumelo marrom',
itemCharcoal = 'Carvão Vegetal',
+
itemCharcoal = 'Carvão vegetal',
 
itemCoal = 'Carvão',
 
itemCoal = 'Carvão',
itemColoredDye = 'Corante Colorido',
+
itemColoredDye = 'Corante colorido',
 
itemDye = 'Corante',
 
itemDye = 'Corante',
 
itemMushroom = 'Cogumelo',
 
itemMushroom = 'Cogumelo',
itemQuartzBlock = 'Bloco de Quartzo',
+
itemQuartzBlock = 'Bloco de quartzo',
itemRedMushroom = 'Cogumelo Vermelho',
+
itemRedMushroom = 'Cogumelo vermelho',
  +
itemStone = 'Pedra',
 
moduleArgs = [[Módulo:ProcessArgs]],
 
moduleArgs = [[Módulo:ProcessArgs]],
 
moduleRecipe = [[Módulo:Recipe table]],
 
moduleRecipe = [[Módulo:Recipe table]],
 
moduleSlot = [[Módulo:Inventory slot]],
 
moduleSlot = [[Módulo:Inventory slot]],
  +
stoneVariants = { 'Pedra', 'Andesito', 'Granito', 'Diorito' },
type = 'Criação',
+
type = 'Fabricação',
 
variantPages = {
 
variantPages = {
'Andesito', 'Estandarte', 'Diorito', 'Estrela de Fogos de Artifício', 'Granito',
+
'Andesito', 'Estandarte', 'Cama', 'Diorito', 'Estrela de fogo de artifício', 'Granito',
'Placa de Pressão', 'Areia', 'Arenito', 'Escudo', 'Laje', 'Painel de Vidro Tingido',
+
'Placa de pressão', 'Areia', 'Arenito', 'Escudo', 'Laje', 'Vidraça tingida',
'Vidro Tingido', 'Escadas', 'Tijolos de Pedra', 'Tábuas', 'Madeira', 'Lã', 'Concreto',
+
'Vidro tingido', 'Escadas', 'Tijolos de pedra', 'Tábuas', 'Madeira', 'Lã', 'Concreto',
  +
'Cimento', 'Azulejo',
'Pó de Concreto', 'Terracota Envidraçada',
 
 
},
 
},
 
}
 
}
Linha 139: Linha 141:
 
 
 
if args.type then
 
if args.type then
categories[cI] = '[[' .. i18n.categoryRecipeType:gsub( '%$1', args.type ) .. ']]'
+
categories[cI] = '[[' .. i18n.categoryRecipeType:gsub( '%$1', args.type:lower() ) .. ']]'
 
cI = cI + 1
 
cI = cI + 1
 
end
 
end
Linha 167: Linha 169:
 
cI = cI + 1
 
cI = cI + 1
 
usedNames[dye] = true
 
usedNames[dye] = true
  +
end
  +
-- List stone variants individually as they have their own pages
  +
elseif
  +
name == slot.i18n.prefixes.any .. ' ' .. i18n.itemStone or
  +
name == i18n.itemStone .. ' ' .. slot.i18n.suffixes.matching
  +
then
  +
for _, stone in pairs( i18n.stoneVariants ) do
  +
categories[cI] = '[[' .. i18n.categoryIngredientUsage:gsub( '%$1', stone ) .. ']]'
  +
cI = cI + 1
  +
usedNames[stone] = true
 
end
 
end
 
else
 
else

Edição atual tal como às 22h14min de 5 de setembro de 2020

Este módulo implementa {{Fabricação}}.

Argumentos pais são automaticamente mesclados com argumentos diretamente passados (o último substituindo o anterior).

Dependências

Veja também

[ver | editar | histórico | purgar]A documentação acima é transcluída de Módulo:Crafting/doc.
local p = {}

local i18n = {
	colored = 'Colorido',
	coloredDyes = {
		'Corante laranja', 'Corante magenta', 'Corante azul-claro', 'Corante amarelo', 'Corante verde-limão',
		'Corante rosa', 'Corante cinza', 'Corante cinza-claro', 'Corante ciano', 'Corante roxo',
		'Corante azul', 'Corante marrom', 'Corante verde', 'Corante vermelho', 'Corante preto',
	},
	categoryIngredientUsage = 'Categoria:Receita usando $1',
	categoryRecipeType = 'Categoria:Receita de $1',
	categoryUpcoming = 'Categoria:Em breve',
	itemBlockOfQuartz = 'Bloco de quartzo',
	itemBoneMeal = 'Farinha de osso',
	itemBrownMushroom = 'Cogumelo marrom',
	itemCharcoal = 'Carvão vegetal',
	itemCoal = 'Carvão',
	itemColoredDye = 'Corante colorido',
	itemDye = 'Corante',
	itemMushroom = 'Cogumelo',
	itemQuartzBlock = 'Bloco de quartzo',
	itemRedMushroom = 'Cogumelo vermelho',
	itemStone = 'Pedra',
	moduleArgs = [[Módulo:ProcessArgs]],
	moduleRecipe = [[Módulo:Recipe table]],
	moduleSlot = [[Módulo:Inventory slot]],
	stoneVariants = { 'Pedra', 'Andesito', 'Granito', 'Diorito' },
	type = 'Fabricação',
	variantPages = {
		'Andesito', 'Estandarte', 'Cama', 'Diorito', 'Estrela de fogo de artifício', 'Granito', 
		'Placa de pressão', 'Areia', 'Arenito', 'Escudo', 'Laje', 'Vidraça tingida', 
		'Vidro tingido', 'Escadas', 'Tijolos de pedra', 'Tábuas', 'Madeira', 'Lã', 'Concreto',
		'Cimento', 'Azulejo',
	},
}
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 then
		categories[cI] = '[[' .. i18n.categoryRecipeType:gsub( '%$1', args.type:lower() ) .. ']]'
		cI = cI + 1
	end
	
	if args.ignoreusage ~= '1' then
		-- Create ingredient categories for DPL
		local usedNames = {}
		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 == i18n.itemDye .. ' ' .. slot.i18n.suffixes.matching or
						name == slot.i18n.prefixes.any .. ' ' .. i18n.itemColoredDye or
						name == i18n.itemColoredDye .. ' '.. slot.i18n.suffixes.matching
					then
						if not name:find( i18n.colored ) then
							categories[cI] = '[[' .. i18n.categoryIngredientUsage:gsub( '%$1', i18n.itemBoneMeal ) .. ']]'
							cI = cI + 1
							usedNames[i18n.itemBoneMeal] = true
						end
						
						for _, dye in ipairs( i18n.coloredDyes ) do
							categories[cI] = '[[' .. i18n.categoryIngredientUsage:gsub( '%$1', dye ) .. ']]'
							cI = cI + 1
							usedNames[dye] = true
						end
					-- List stone variants individually as they have their own pages
					elseif
						name == slot.i18n.prefixes.any .. ' ' .. i18n.itemStone or
						name == i18n.itemStone .. ' ' .. slot.i18n.suffixes.matching
					then
						for _, stone in pairs( i18n.stoneVariants ) do
							categories[cI] = '[[' .. i18n.categoryIngredientUsage:gsub( '%$1', stone ) .. ']]'
							cI = cI + 1
							usedNames[stone] = true
						end
					else
						-- Merge item variants which use a single page
						if
							name == slot.i18n.prefixes.any .. ' ' .. i18n.itemMushroom or
							name == i18n.itemMushroom .. ' ' .. slot.i18n.suffixes.matching 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 _, suffix in pairs( slot.i18n.suffixes ) do
								if name:find( ' ' .. suffix .. '$' ) then
									name = name:gsub( suffix .. '$', '' )
									break
								end
							end
						end
						
						if not usedNames[name] then
							categories[cI] = '[[' .. i18n.categoryIngredientUsage:gsub( '%$1', name ) .. ']]'
							cI = cI + 1
							usedNames[name] = true
						end
					end
				end
			end
		end
	end
	
	return out, table.concat( categories, '' )
end

return p