mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-09-29 00:21:53 +02:00
Comments on crafting.lua
This commit is contained in:
parent
65af733e4f
commit
b71936dbc3
@ -1,39 +1,28 @@
|
|||||||
minetest.register_craft({
|
--- This function determines the format of the crafting recipe in the crafting grid based on the
|
||||||
output = "mcl_copper:block_raw",
|
---block name. Each block must have its own crafting format for the given material(s).
|
||||||
recipe = {
|
---Some materials in the recipe can be pre-defined (e.g. copper bulbs have fixed materials
|
||||||
{ "mcl_copper:raw_copper", "mcl_copper:raw_copper", "mcl_copper:raw_copper" },
|
--(blaze stick and redstone) and materials that vary according to the material parameter)
|
||||||
{ "mcl_copper:raw_copper", "mcl_copper:raw_copper", "mcl_copper:raw_copper" },
|
---@param name string
|
||||||
{ "mcl_copper:raw_copper", "mcl_copper:raw_copper", "mcl_copper:raw_copper" },
|
---@param material string
|
||||||
},
|
---@return table
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craft({
|
|
||||||
output = "mcl_copper:block",
|
|
||||||
recipe = {
|
|
||||||
{ "mcl_copper:copper_ingot", "mcl_copper:copper_ingot", "mcl_copper:copper_ingot" },
|
|
||||||
{ "mcl_copper:copper_ingot", "mcl_copper:copper_ingot", "mcl_copper:copper_ingot" },
|
|
||||||
{ "mcl_copper:copper_ingot", "mcl_copper:copper_ingot", "mcl_copper:copper_ingot" },
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
local function get_shape(name, material)
|
local function get_shape(name, material)
|
||||||
if name == "cut" then
|
if name == "cut" then -- Shape of cut copper blocks
|
||||||
return {
|
return {
|
||||||
{material, material},
|
{material, material},
|
||||||
{material, material}
|
{material, material}
|
||||||
}
|
}
|
||||||
elseif name == "grate" then
|
elseif name == "grate" then -- Shape of copper grates
|
||||||
return {
|
return {
|
||||||
{"", material, ""},
|
{"", material, ""},
|
||||||
{material, "", material},
|
{material, "", material},
|
||||||
{"", material, ""}
|
{"", material, ""}
|
||||||
}
|
}
|
||||||
elseif name == "chiseled" then
|
elseif name == "chiseled" then -- Shape of chiseled copper blocks
|
||||||
return {
|
return {
|
||||||
{material},
|
{material},
|
||||||
{material},
|
{material},
|
||||||
}
|
}
|
||||||
elseif name == "bulb_off" then
|
elseif name == "bulb_off" then -- Shape of copper bulbs (with fixed materials)
|
||||||
return {
|
return {
|
||||||
{"", material, ""},
|
{"", material, ""},
|
||||||
{material, "mcl_mobitems:blaze_rod", material},
|
{material, "mcl_mobitems:blaze_rod", material},
|
||||||
@ -44,10 +33,19 @@ local function get_shape(name, material)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- This function is responsible for recording the recipes for each block (including oxidized variants).
|
||||||
|
--- If the recipe's main material is the Block of Copper, the material parameter must be passed as "block".
|
||||||
|
--- If the main material is another block (as in the case of the chiseled copper block), the material
|
||||||
|
--- parameter must be a table containing 8 itemstrings of the blocks used in the recipes.
|
||||||
|
--- Special fixed materials (such as copper bulbs) must be registered to the crafting grid format in the
|
||||||
|
--- get_shape function.
|
||||||
|
---@param name string
|
||||||
|
---@param material string|table
|
||||||
|
---@param amount integer
|
||||||
local function register_variants_recipes(name, material, amount)
|
local function register_variants_recipes(name, material, amount)
|
||||||
local names
|
local names
|
||||||
local materials = {}
|
local materials = {}
|
||||||
|
-- Handling the inconsistency of the original itemstrings
|
||||||
if name ~= "cut" then
|
if name ~= "cut" then
|
||||||
names = {
|
names = {
|
||||||
name, "waxed_"..name,
|
name, "waxed_"..name,
|
||||||
@ -63,7 +61,7 @@ local function register_variants_recipes(name, material, amount)
|
|||||||
"block_oxidized_"..name, "waxed_block_oxidized_"..name
|
"block_oxidized_"..name, "waxed_block_oxidized_"..name
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
-- Checking the type of material
|
||||||
if type(material) == "string" then
|
if type(material) == "string" then
|
||||||
materials = {
|
materials = {
|
||||||
"mcl_copper:"..material, "mcl_copper:waxed_"..material,
|
"mcl_copper:"..material, "mcl_copper:waxed_"..material,
|
||||||
@ -74,7 +72,10 @@ local function register_variants_recipes(name, material, amount)
|
|||||||
else
|
else
|
||||||
materials = material
|
materials = material
|
||||||
end
|
end
|
||||||
|
--[[
|
||||||
|
Registering each recipe according to the materials
|
||||||
|
blocks made from copper and its oxidized and waxed variations)
|
||||||
|
]]
|
||||||
for i = 1, 8 do
|
for i = 1, 8 do
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "mcl_copper:"..names[i].." "..tostring(amount),
|
output = "mcl_copper:"..names[i].." "..tostring(amount),
|
||||||
@ -82,11 +83,11 @@ local function register_variants_recipes(name, material, amount)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- Using the function above to record the recipes for cut copper blocks, copper grates and copper bulbs
|
||||||
register_variants_recipes("cut", "block", 4)
|
register_variants_recipes("cut", "block", 4)
|
||||||
register_variants_recipes("grate", "block", 4)
|
register_variants_recipes("grate", "block", 4)
|
||||||
register_variants_recipes("bulb_off", "block", 4)
|
register_variants_recipes("bulb_off", "block", 4)
|
||||||
|
-- Chiseled copper uses slabs as the main material.
|
||||||
local chiseled_materials = {
|
local chiseled_materials = {
|
||||||
"mcl_stairs:slab_copper_cut",
|
"mcl_stairs:slab_copper_cut",
|
||||||
"mcl_stairs:slab_waxed_copper_cut",
|
"mcl_stairs:slab_waxed_copper_cut",
|
||||||
@ -97,9 +98,9 @@ local chiseled_materials = {
|
|||||||
"mcl_stairs:slab_copper_oxidized_cut",
|
"mcl_stairs:slab_copper_oxidized_cut",
|
||||||
"mcl_stairs:slab_waxed_copper_oxidized_cut"
|
"mcl_stairs:slab_waxed_copper_oxidized_cut"
|
||||||
}
|
}
|
||||||
|
-- Registering recipes for chiseled copper blocks using the slabs.
|
||||||
register_variants_recipes("chiseled", chiseled_materials, 1)
|
register_variants_recipes("chiseled", chiseled_materials, 1)
|
||||||
|
-- List of blocks that can be waxed.
|
||||||
local waxable_blocks = {
|
local waxable_blocks = {
|
||||||
"block",
|
"block",
|
||||||
"block_cut",
|
"block_cut",
|
||||||
@ -122,7 +123,7 @@ local waxable_blocks = {
|
|||||||
"chiseled_oxidized",
|
"chiseled_oxidized",
|
||||||
"bulb_off_oxidized"
|
"bulb_off_oxidized"
|
||||||
}
|
}
|
||||||
|
-- Registering the waxing recipes for each block listed above.
|
||||||
for _, w in ipairs(waxable_blocks) do
|
for _, w in ipairs(waxable_blocks) do
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "mcl_copper:waxed_"..w,
|
output = "mcl_copper:waxed_"..w,
|
||||||
@ -131,7 +132,7 @@ for _, w in ipairs(waxable_blocks) do
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
-- List of blocks that can be cutted on stonecutter
|
||||||
local cuttable_blocks = {
|
local cuttable_blocks = {
|
||||||
"block",
|
"block",
|
||||||
"waxed_block",
|
"waxed_block",
|
||||||
@ -142,13 +143,31 @@ local cuttable_blocks = {
|
|||||||
"block_oxidized",
|
"block_oxidized",
|
||||||
"waxed_block_oxidized"
|
"waxed_block_oxidized"
|
||||||
}
|
}
|
||||||
|
-- Registering stonecutter recipes using the blocks listed above.
|
||||||
for _, c in ipairs(cuttable_blocks) do
|
for _, c in ipairs(cuttable_blocks) do
|
||||||
mcl_stonecutter.register_recipe("mcl_copper:"..c, "mcl_copper:"..c.."_cut", 4)
|
mcl_stonecutter.register_recipe("mcl_copper:"..c, "mcl_copper:"..c.."_cut", 4)
|
||||||
--mcl_stonecutter.register_recipe("mcl_copper:"..c, "mcl_copper:"..c:gsub("block", "grate"), 4)
|
--mcl_stonecutter.register_recipe("mcl_copper:"..c, "mcl_copper:"..c:gsub("block", "grate"), 4)
|
||||||
--mcl_stonecutter.register_recipe("mcl_copper:"..c, "mcl_copper:"..c:gsub("block", "chiseled"), 4)
|
--mcl_stonecutter.register_recipe("mcl_copper:"..c, "mcl_copper:"..c:gsub("block", "chiseled"), 4)
|
||||||
--mcl_stonecutter.register_recipe("mcl_copper:"..c.."_cut", "mcl_copper:"..c:gsub("block", "chiseled"))
|
--mcl_stonecutter.register_recipe("mcl_copper:"..c.."_cut", "mcl_copper:"..c:gsub("block", "chiseled"))
|
||||||
end
|
end
|
||||||
|
-- Registering blocks and items specific recipes
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "mcl_copper:block_raw",
|
||||||
|
recipe = {
|
||||||
|
{ "mcl_copper:raw_copper", "mcl_copper:raw_copper", "mcl_copper:raw_copper" },
|
||||||
|
{ "mcl_copper:raw_copper", "mcl_copper:raw_copper", "mcl_copper:raw_copper" },
|
||||||
|
{ "mcl_copper:raw_copper", "mcl_copper:raw_copper", "mcl_copper:raw_copper" },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "mcl_copper:block",
|
||||||
|
recipe = {
|
||||||
|
{ "mcl_copper:copper_ingot", "mcl_copper:copper_ingot", "mcl_copper:copper_ingot" },
|
||||||
|
{ "mcl_copper:copper_ingot", "mcl_copper:copper_ingot", "mcl_copper:copper_ingot" },
|
||||||
|
{ "mcl_copper:copper_ingot", "mcl_copper:copper_ingot", "mcl_copper:copper_ingot" },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "mcl_copper:copper_ingot 9",
|
output = "mcl_copper:copper_ingot 9",
|
||||||
|
Loading…
Reference in New Issue
Block a user