Comments and corrections

This commit is contained in:
JoseDouglas26 2024-05-06 11:25:32 -03:00
parent 1da49026ab
commit 6c84848bce
4 changed files with 38 additions and 36 deletions

View File

@ -32,7 +32,6 @@ local function get_shape(name, material)
return {}
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
@ -72,10 +71,8 @@ local function register_variants_recipes(name, material, amount)
else
materials = material
end
--[[
Registering each recipe according to the materials
blocks made from copper and its oxidized and waxed variations).
]]
-- Registering each recipe according to the materials blocks made from copper and its oxidized and
-- waxed variations.
for i = 1, 8 do
minetest.register_craft({
output = "mcl_copper:"..names[i].." "..tostring(amount),
@ -85,7 +82,9 @@ local function register_variants_recipes(name, material, amount)
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("grate", "block", 4)
register_variants_recipes("bulb_off", "block", 4)
-- Chiseled copper uses slabs as the main material.
local chiseled_materials = {

View File

@ -52,12 +52,13 @@ local function register_oxidation_and_scraping(mod_name, subname, decay_chain)
end
end
end
--- Function used to define the waxed and stripped variants (for the waxed variants) of copper-related
--- blocks that are registered by APIs external to mcl_copper (stairs, slabs, doors and trapdoors).
--- "mod_name" should be the name of the mod the blocks belong to. "subname" must be the subname of the
--- block that will receive the changes (see registered subnames below). "decay_chain" should be a table
--- containing the list of subnames of the block oxidation chain (without the waxed variants subnames).
function register_waxing_and_scraping(mod_name, subname, decay_chain)
local function register_waxing_and_scraping(mod_name, subname, decay_chain)
local waxed_item, unwaxed_item
for i = 1, #decay_chain do
@ -119,10 +120,17 @@ local doors_decay_chain = {
}
-- Defining variants for copper-related blocks that are registered by external APIs.
register_oxidation_and_scraping("mcl_stairs", "stair_copper", cut_decay_chain)
register_oxidation_and_scraping("mcl_stairs", "slab_copper", cut_decay_chain)
register_oxidation_and_scraping("mcl_copper", "trapdoor", doors_decay_chain)
register_oxidation_and_scraping("mcl_copper", "door", doors_decay_chain)
register_waxing_and_scraping("mcl_stairs", "stair_waxed_copper", cut_decay_chain)
register_waxing_and_scraping("mcl_stairs", "slab_waxed_copper", cut_decay_chain)
register_waxing_and_scraping("mcl_copper", "waxed_trapdoor", doors_decay_chain)
register_waxing_and_scraping("mcl_copper", "waxed_door", doors_decay_chain)

View File

@ -10,8 +10,6 @@ dofile(path .. "/nodes.lua")
dofile(path .. "/items.lua")
-- Loading the file that registers the blocks crafting recipes
dofile(path .. "/crafting.lua")
--[[
Loading the file that handles oxidized, waxed and stripped variants for blocks that are registered
in other mods and normally do not have these variants.
]]
-- Loading the file that handles oxidized, waxed and stripped variants for blocks that are registered
-- in other mods and normally do not have these variants.
dofile(path .. "/functions.lua")

View File

@ -16,7 +16,14 @@ local function set_drop(drop, old_name, index_name)
return drop
end
--- Function used to set special groups for some blocks based on its names.
--- "oxidizable" is the group that indicates that the block can oxidize.
--- "waxed" is the group that indicates that the block can not oxidize.
--- Doors and trapdoors they will be part of groups related to mesecon, indicating that mesecon
--- (redstone) has an effect on them.
---@param name string
---@param groups table
---@return table|nil
local function set_groups(name, groups)
local groups = table.copy(groups)
@ -52,7 +59,7 @@ local function set_light_level(light_source, index)
return light_source
end
--- Function used to set tiles for blocks. "tiles" must be a table with 4 values as the waxed variants
--- Function used to set tiles for blocks. "tiles" must be a table with 4 values as waxed variants
--- use the same textures as the unwaxed versions. "index" must be an integer that must be, at most,
--- twice the number of textures in the table (8 as the maximum value).
---@param tiles table
@ -109,24 +116,18 @@ local function register_copper_variants(name, definitions)
end
-- Registering the 8 nodes in the oxidation chain.
for i = 1, #names do
--[[
Defining whether the block is waxed and defining its stripped variant (its non-oxidized
variant, which must precede the waxed variant in the name table).
]]
-- Defining whether the block is waxed and defining its stripped variant (its non-oxidized
-- variant, which must precede the waxed variant in the name table).
if names[i]:find("waxed") then
stripped_variant = "mcl_copper:"..names[i-1]
else
--[[
While the "oxidized" variant is not found, this snippet defines the oxidized variant of
the block.
]]
-- While the "oxidized" variant is not found, this snippet defines the oxidized variant of
-- the block.
if not names[i]:find("oxidized") then
oxidized_variant = "mcl_copper:"..names[i+2]
end
--[[
Defining the stripped variant with the exception of the first block in the chain
(and the waxed ones that were defined before).
]]
-- Defining the stripped variant with the exception of the first block in the chain
-- (and the waxed ones that were defined before).
if i ~= 1 then
stripped_variant = "mcl_copper:"..names[i-2]
end
@ -176,14 +177,12 @@ local function register_copper_variants(name, definitions)
-- Defining the special groups for doors and trapdoors.
local door_groups = set_groups(names[i]:gsub(name, "door"), definitions.groups)
local trapdoor_groups = set_groups(names[i]:gsub(name, "trapdoor"), definitions.groups)
--[[
Managing the textures related to doors and trapdoors, as well as the texture of the item
for each door. As with the other blocks, the waxed variant uses the same textures as the
unwaxed variants.
itemimg -> item image for the doors on inventory;
lowertext / uppertext -> lower and bottom textures for the doors;
frontimg / sideimg -> front and side textures for the trapdoors;
]]
-- Managing the textures related to doors and trapdoors, as well as the texture of the item
-- for each door. As with the other blocks, the waxed variant uses the same textures as the
-- unwaxed variants.
-- itemimg -> item image for the doors on inventory;
-- lowertext / uppertext -> lower and bottom textures for the doors;
-- frontimg / sideimg -> front and side textures for the trapdoors;
if i % 2 == 1 then
itemimg = "mcl_copper_item_"..names[i]:gsub(name, "door")..".png"
lowertext = "mcl_copper_"..names[i]:gsub(name, "door").."_lower.png"
@ -231,10 +230,8 @@ end
-- Using the function above to register the copper blocks.
register_copper_variants("block", {
groups = {pickaxey = 2, building_block = 1},
--[[
Copper blocks are no longer the manufacturing material for doors but this definition will be
maintained here to avoid individual registration of 16 blocks.
]]
-- Copper blocks are no longer the manufacturing material for doors but this definition will be
-- maintained here to avoid individual registration of 16 blocks.
_mcl_doors = true,
})
-- Using the function above to register the cut copper blocks.