Removal of global functions and bug fixes

This commit is contained in:
JoseDouglas26 2024-05-05 06:25:36 -03:00
parent 73f96ed5f3
commit 1eaca376e9
3 changed files with 105 additions and 123 deletions

View file

@ -44,9 +44,10 @@ local function get_shape(name, material)
end
end
function mcl_copper.register_variants_recipes(name, material, amount)
local function register_variants_recipes(name, material, amount)
local names
local materials = {}
if name ~= "cut" then
names = {
name, "waxed_"..name,
@ -70,14 +71,8 @@ function mcl_copper.register_variants_recipes(name, material, amount)
"mcl_copper:"..material.."_weathered", "mcl_copper:waxed_"..material.."_weathered",
"mcl_copper:"..material.."_oxidized", "mcl_copper:waxed_"..material.."_oxidized"
}
elseif type(material) == "table" then
if #material == 8 then
materials = material
else
return
end
else
return
materials = material
end
for i = 1, 8 do
@ -88,9 +83,9 @@ function mcl_copper.register_variants_recipes(name, material, amount)
end
end
mcl_copper.register_variants_recipes("cut", "block", 4)
mcl_copper.register_variants_recipes("grate", "block", 4)
mcl_copper.register_variants_recipes("bulb_off", "block", 4)
register_variants_recipes("cut", "block", 4)
register_variants_recipes("grate", "block", 4)
register_variants_recipes("bulb_off", "block", 4)
local chiseled_materials = {
"mcl_stairs:slab_copper_cut",
@ -103,7 +98,7 @@ local chiseled_materials = {
"mcl_stairs:slab_waxed_copper_oxidized_cut"
}
mcl_copper.register_variants_recipes("chiseled", chiseled_materials, 1)
register_variants_recipes("chiseled", chiseled_materials, 1)
local waxable_blocks = {
"block",

View file

@ -1,106 +1,107 @@
local S = minetest.get_translator("mcl_copper")
local lit_desc = "(Lit)"
local pow_desc = "(Powered)"
local mix_desc = "(Lit and Powered)"
mcl_copper.copper_descs = {
["block"] = {
"Block of Copper", "Waxed Block of Copper",
"Exposed Copper", "Waxed Exposed Copper",
"Weathered Copper", "Waxed Weathered Copper",
"Oxidized Copper", "Waxed Oxidized Copper"
S("Block of Copper"), S("Waxed Block of Copper"),
S("Exposed Copper"), S("Waxed Exposed Copper"),
S("Weathered Copper"), S("Waxed Weathered Copper"),
S("Oxidized Copper"), S("Waxed Oxidized Copper")
},
["cut"] = {
"Cut Copper", "Waxed Cut Copper",
"Exposed Cut Copper", "Waxed Exposed Cut Copper",
"Weathered Cut Copper", "Waxed Weathered Cut Copper",
"Oxidized Cut Copper", "Waxed Oxidized Cut Copper"
S("Cut Copper"), S("Waxed Cut Copper"),
S("Exposed Cut Copper"), S("Waxed Exposed Cut Copper"),
S("Weathered Cut Copper"), S("Waxed Weathered Cut Copper"),
S("Oxidized Cut Copper"), S("Waxed Oxidized Cut Copper")
},
["grate"] = {
"Copper Grate", "Waxed Copper Grate",
"Exposed Copper Grate", "Waxed Exposed Copper Grate",
"Weathered Copper Grate", "Waxed Weathered Copper Grate",
"Oxidized Copper Grate", "Waxed Oxidized Copper Grate"
S("Copper Grate"), S("Waxed Copper Grate"),
S("Exposed Copper Grate"), S("Waxed Exposed Copper Grate"),
S("Weathered Copper Grate"), S("Waxed Weathered Copper Grate"),
S("Oxidized Copper Grate"), S("Waxed Oxidized Copper Grate")
},
["chiseled"] = {
"Chiseled Copper", "Waxed Chiseled Copper",
"Exposed Chiseled Copper", "Waxed Exposed Chiseled Copper",
"Weathered Chiseled Copper", "Waxed Weathered Chiseled Copper",
"Oxidized Chiseled Copper", "Waxed Oxidized Chiseled Copper"
S("Chiseled Copper"), S("Waxed Chiseled Copper"),
S("Exposed Chiseled Copper"), S("Waxed Exposed Chiseled Copper"),
S("Weathered Chiseled Copper"), S("Waxed Weathered Chiseled Copper"),
S("Oxidized Chiseled Copper"), S("Waxed Oxidized Chiseled Copper")
},
["bulb_off"] = {
"Copper Bulb", "Waxed Copper Bulb",
"Exposed Copper Bulb", "Waxed Exposed Copper Bulb",
"Weathered Copper Bulb", "Waxed Weathered Copper Bulb",
"Oxidized Copper Bulb", "Waxed Oxidized Copper Bulb"
S("Copper Bulb"), S("Waxed Copper Bulb"),
S("Exposed Copper Bulb"), S("Waxed Exposed Copper Bulb"),
S("Weathered Copper Bulb"), S("Waxed Weathered Copper Bulb"),
S("Oxidized Copper Bulb"), S("Waxed Oxidized Copper Bulb")
},
["bulb_on"] = {
{"Copper Bulb", lit_desc}, {"Waxed Copper Bulb", lit_desc},
{"Exposed Copper Bulb", lit_desc}, {"Waxed Exposed Copper Bulb", lit_desc},
{"Weathered Copper Bulb", lit_desc}, {"Waxed Weathered Copper Bulb", lit_desc},
{"Oxidized Copper Bulb", lit_desc}, {"Waxed Oxidized Copper Bulb", lit_desc}
S("Copper Bulb "..lit_desc), S("Waxed Copper Bulb "..lit_desc),
S("Exposed Copper Bulb "..lit_desc), S("Waxed Exposed Copper Bulb "..lit_desc),
S("Weathered Copper Bulb "..lit_desc), S("Waxed Weathered Copper Bulb "..lit_desc),
S("Oxidized Copper Bulb "..lit_desc), S("Waxed Oxidized Copper Bulb "..lit_desc)
},
["bulb_powered_off"] = {
{"Copper Bulb", pow_desc}, {"Waxed Copper Bulb", pow_desc},
{"Exposed Copper Bulb", pow_desc}, {"Waxed Exposed Copper Bulb", pow_desc},
{"Weathered Copper Bulb", pow_desc}, {"Waxed Weathered Copper Bulb", pow_desc},
{"Oxidized Copper Bulb", pow_desc}, {"Waxed Oxidized Copper Bulb", pow_desc}
S("Copper Bulb "..pow_desc), S("Waxed Copper Bulb "..pow_desc),
S("Exposed Copper Bulb "..pow_desc), S("Waxed Exposed Copper Bulb "..pow_desc),
S("Weathered Copper Bulb "..pow_desc), S("Waxed Weathered Copper Bulb "..pow_desc),
S("Oxidized Copper Bulb "..pow_desc), S("Waxed Oxidized Copper Bulb "..pow_desc)
},
["bulb_powered_on"] = {
{"Copper Bulb", mix_desc}, {"Waxed Copper Bulb", mix_desc},
{"Exposed Copper Bulb", mix_desc}, {"Waxed Exposed Copper Bulb", mix_desc},
{"Weathered Copper Bulb", mix_desc}, {"Waxed Weathered Copper Bulb", mix_desc},
{"Oxidized Copper Bulb", mix_desc}, {"Waxed Oxidized Copper Bulb", mix_desc}
S("Copper Bulb "..mix_desc), S("Waxed Copper Bulb "..mix_desc),
S("Exposed Copper Bulb "..mix_desc), S("Waxed Exposed Copper Bulb "..mix_desc),
S("Weathered Copper Bulb "..mix_desc), S("Waxed Weathered Copper Bulb "..mix_desc),
S("Oxidized Copper Bulb "..mix_desc), S("Waxed Oxidized Copper Bulb "..mix_desc)
}
}
mcl_copper.copper_longdescs = {
["block"] = {
"A block of copper is mostly a decorative block.",
"Exposed copper is a decorative block.",
"Weathered copper is a decorative block.",
"Oxidized copper is a decorative block."
S("A block of copper is mostly a decorative block."),
S("Exposed copper is a decorative block."),
S("Weathered copper is a decorative block."),
S("Oxidized copper is a decorative block.")
},
["cut"] = {
"Cut copper is a decorative block.",
"Exposed cut copper is a decorative block.",
"Weathered cut copper is a decorative block.",
"Oxidized cut copper is a decorative block."
S("Cut copper is a decorative block."),
S("Exposed cut copper is a decorative block."),
S("Weathered cut copper is a decorative block."),
S("Oxidized cut copper is a decorative block.")
},
["grate"] = {
"Copper grate is a decorative block.",
"Exposed copper grate is a decorative block.",
"Weathered copper grate is a decorative block.",
"Oxidized copper grate is a decorative block."
S("Copper grate is a decorative block."),
S("Exposed copper grate is a decorative block."),
S("Weathered copper grate is a decorative block."),
S("Oxidized copper grate is a decorative block.")
},
["chiseled"] = {
"Chiseled copper is a decorative block.",
"Exposed chiseled copper is a decorative block.",
"Weathered chiseled copper is a decorative block.",
"Oxidized chiseled copper is a decorative block."
S("Chiseled copper is a decorative block."),
S("Exposed chiseled copper is a decorative block."),
S("Weathered chiseled copper is a decorative block."),
S("Oxidized chiseled copper is a decorative block.")
},
["bulb_off"] = {
"Copper bulb is a decorative block and a light source when lited.",
"Exposed copper bulb is a decorative block and a light source when lited.",
"Weathered copper bulb is a decorative block and a light source when lited.",
"Oxidized copper bulb is a decorative block and a light source when lited."
S("Copper bulb is a decorative block and a light source when lited."),
S("Exposed copper bulb is a decorative block and a light source when lited."),
S("Weathered copper bulb is a decorative block and a light source when lited."),
S("Oxidized copper bulb is a decorative block and a light source when lited.")
},
["bulb_on"] = {
"Copper bulb is a decorative block and a light source.",
"Exposed copper bulb is a decorative block and a light source.",
"Weathered copper bulb is a decorative block and a light source.",
"Oxidized copper bulb is a decorative block and a light source."
S("Copper bulb is a decorative block and a light source."),
S("Exposed copper bulb is a decorative block and a light source."),
S("Weathered copper bulb is a decorative block and a light source."),
S("Oxidized copper bulb is a decorative block and a light source.")
},
["bulb_powered_off"] = {
"Copper bulb is a decorative block and a light source when lited.",
"Exposed copper bulb is a decorative block and a light source when lited.",
"Weathered copper bulb is a decorative block and a light source when lited.",
"Oxidized copper bulb is a decorative block and a light source when lited."
S("Copper bulb is a decorative block and a light source when lited."),
S("Exposed copper bulb is a decorative block and a light source when lited."),
S("Weathered copper bulb is a decorative block and a light source when lited."),
S("Oxidized copper bulb is a decorative block and a light source when lited.")
},
["bulb_powered_on"] = {
"Copper bulb is a decorative block and a light source.",
"Exposed copper bulb is a decorative block and a light source.",
"Weathered copper bulb is a decorative block and a light source.",
"Oxidized copper bulb is a decorative block and a light source."
S("Copper bulb is a decorative block and a light source."),
S("Exposed copper bulb is a decorative block and a light source."),
S("Weathered copper bulb is a decorative block and a light source."),
S("Oxidized copper bulb is a decorative block and a light source.")
}
}
@ -115,38 +116,38 @@ mcl_copper.stairs_subnames = {
mcl_copper.stairs_descs = {
["copper_cut"] = {
"Slab of Cut Copper", "Double Slab of Cut Copper", "Stairs of Cut Copper",
S("Slab of Cut Copper"), S("Double Slab of Cut Copper"), S("Stairs of Cut Copper"),
},
["waxed_copper_cut"] = {
"Waxed Slab of Cut Copper", "Waxed Double Slab of Cut Copper", "Waxed Stairs of Cut Copper",
S("Waxed Slab of Cut Copper"), S("Waxed Double Slab of Cut Copper"), S("Waxed Stairs of Cut Copper"),
},
["copper_exposed_cut"] = {
"Slab of Exposed Cut Copper", "Double Slab of Exposed Cut Copper", "Stairs of Exposed Cut Copper"
S("Slab of Exposed Cut Copper"), S("Double Slab of Exposed Cut Copper"), S("Stairs of Exposed Cut Copper")
},
["waxed_copper_exposed_cut"] = {
"Waxed Slab of Exposed Cut Copper", "Waxed Double Slab of Exposed Cut Copper", "Waxed Stairs of Exposed Cut Copper"
S("Waxed Slab of Exposed Cut Copper"), S("Waxed Double Slab of Exposed Cut Copper"), S("Waxed Stairs of Exposed Cut Copper")
},
["copper_weathered_cut"] = {
"Slab of Weathered Cut Copper", "Double Slab of Weathered Cut Copper", "Stairs of Weathered Cut Copper"
S("Slab of Weathered Cut Copper"), S("Double Slab of Weathered Cut Copper"), S("Stairs of Weathered Cut Copper")
},
["waxed_copper_weathered_cut"] = {
"Waxed Slab of Weathered Cut Copper", "Waxed Double Slab of Weathered Cut Copper", "Waxed Stairs of Weathered Cut Copper"
S("Waxed Slab of Weathered Cut Copper"), S("Waxed Double Slab of Weathered Cut Copper"), S("Waxed Stairs of Weathered Cut Copper")
},
["copper_oxidized_cut"] = {
"Slab of Oxidized Cut Copper", "Double Slab of Oxidized Cut Copper", "Stairs of Oxidized Cut Copper"
S("Slab of Oxidized Cut Copper"), S("Double Slab of Oxidized Cut Copper"), S("Stairs of Oxidized Cut Copper")
},
["waxed_copper_oxidized_cut"] = {
"Waxed Slab of Oxidized Cut Copper", "Waxed Double Slab of Oxidized Cut Copper", "Waxed Stairs of Oxidized Cut Copper"
S("Waxed Slab of Oxidized Cut Copper"), S("Waxed Double Slab of Oxidized Cut Copper"), S("Waxed Stairs of Oxidized Cut Copper")
}
}
mcl_copper.doors_descs = {
{"Copper Door", "Copper Trapdoor"},
{"Waxed Copper Door", "Waxed Copper Trapdoor"},
{"Exposed Copper Door", "Exposed Copper Trapdoor"},
{"Waxed Exposed Copper Door", "Waxed Exposed Copper Trapdoor"},
{"Weathered Copper Door", "Weathered Copper Trapdoor"},
{"Waxed Weathered Copper Door", "Waxed Weathered Copper Trapdoor"},
{"Oxidized Copper Door", "Oxidized Copper Trapdoor"},
{"Waxed Oxidized Copper Door", "Waxed Oxidized Copper Trapdoor"}
{S("Copper Door"), S("Copper Trapdoor")},
{S("Waxed Copper Door"), S("Waxed Copper Trapdoor")},
{S("Exposed Copper Door"), S("Exposed Copper Trapdoor")},
{S("Waxed Exposed Copper Door"), S("Waxed Exposed Copper Trapdoor")},
{S("Weathered Copper Door"), S("Weathered Copper Trapdoor")},
{S("Waxed Weathered Copper Door"), S("Waxed Weathered Copper Trapdoor")},
{S("Oxidized Copper Door"), S("Oxidized Copper Trapdoor")},
{S("Waxed Oxidized Copper Door"), S("Waxed Oxidized Copper Trapdoor")}
}

View file

@ -1,19 +1,5 @@
local S = minetest.get_translator("mcl_copper")
local function set_description(descs, s_index, n_index)
local description
if type(descs[s_index][n_index]) == "string" then
description = S(descs[s_index][n_index])
elseif type(descs[s_index][n_index]) == "table" then
description = S("@1 "..descs[s_index][n_index][2], S(descs[s_index][n_index][1]))
else
return nil
end
return description
end
local function set_drop(drop, old_name, index_name)
if drop and old_name and index_name then
drop = "mcl_copper:"..old_name:gsub(index_name, drop)
@ -60,7 +46,7 @@ local function set_tiles(tiles, index)
return tiles[math.ceil(index / 2)]
end
function mcl_copper.register_copper_variants(name, definitions)
local function register_copper_variants(name, definitions)
local names, oxidized_variant, stripped_variant, waxed_variant, tiles
if name ~= "cut" then
@ -109,7 +95,7 @@ function mcl_copper.register_copper_variants(name, definitions)
end
minetest.register_node("mcl_copper:"..names[i], {
description = set_description(mcl_copper.copper_descs, name, i),
description = mcl_copper.copper_descs[name][i],
drawtype = definitions.drawtype or "normal",
drop = set_drop(definitions.drop, names[i], name),
groups = set_groups(names[i], definitions.groups),
@ -121,7 +107,7 @@ function mcl_copper.register_copper_variants(name, definitions)
sounds = mcl_sounds.node_sound_metal_defaults(),
sunlight_propagates = definitions.sunlight_propagates or false,
tiles = {set_tiles(tiles, i)},
_doc_items_longdesc = S(mcl_copper.copper_longdescs[name][math.ceil(i/2)]),
_doc_items_longdesc = mcl_copper.copper_longdescs[name][math.ceil(i/2)],
_mcl_blast_resistance = 6,
_mcl_hardness = 3,
_mcl_oxidized_variant = oxidized_variant,
@ -134,14 +120,14 @@ function mcl_copper.register_copper_variants(name, definitions)
mcl_stairs.register_slab(subname, "mcl_copper:"..names[i], set_groups(subname, definitions.groups),
{set_tiles(tiles, i), set_tiles(tiles, i), set_tiles(tiles, i)},
set_description(mcl_copper.stairs_descs, subname, 1), nil, nil, nil,
set_description(mcl_copper.stairs_descs, subname, 2)
mcl_copper.stairs_descs[subname][1], nil, nil, nil,
mcl_copper.stairs_descs[subname][2]
)
mcl_stairs.register_stair(subname, "mcl_copper:"..names[i], set_groups(subname, definitions.groups),
{set_tiles(tiles, i), set_tiles(tiles, i), set_tiles(tiles, i),
set_tiles(tiles, i), set_tiles(tiles, i), set_tiles(tiles, i)},
set_description(mcl_copper.stairs_descs, subname, 3), nil, nil, nil, "woodlike"
mcl_copper.stairs_descs[subname][3], nil, nil, nil, "woodlike"
)
end
@ -165,7 +151,7 @@ function mcl_copper.register_copper_variants(name, definitions)
end
mcl_doors:register_door("mcl_copper:"..names[i]:gsub(name, "door"), {
description = S(mcl_copper.doors_descs[i][1]),
description = mcl_copper.doors_descs[i][1],
groups = door_groups,
inventory_image = itemimg,
only_redstone_can_open = false,
@ -179,7 +165,7 @@ function mcl_copper.register_copper_variants(name, definitions)
})
mcl_doors:register_trapdoor("mcl_copper:"..names[i]:gsub(name, "trapdoor"), {
description = S(mcl_copper.doors_descs[i][2]),
description = mcl_copper.doors_descs[i][2],
groups = trapdoor_groups,
only_redstone_can_open = false,
sounds = mcl_sounds.node_sound_metal_defaults(),
@ -212,7 +198,7 @@ minetest.register_node("mcl_copper:stone_with_copper", {
minetest.register_node("mcl_copper:block_raw", {
description = S("Block of Raw Copper"),
_doc_items_longdesc = S("A block used for compact raw copper storage."),
tiles = {"mcl_copper_raw_block.png"},
tiles = {"mcl_copper_block_raw.png"},
is_ground_content = false,
groups = {pickaxey = 2, building_block = 1, blast_furnace_smeltable = 1},
sounds = mcl_sounds.node_sound_metal_defaults(),
@ -220,27 +206,27 @@ minetest.register_node("mcl_copper:block_raw", {
_mcl_hardness = 5,
})
mcl_copper.register_copper_variants("block", {
register_copper_variants("block", {
groups = {pickaxey = 2, building_block = 1},
_mcl_doors = true,
})
mcl_copper.register_copper_variants("cut", {
register_copper_variants("cut", {
groups = {pickaxey = 2, building_block = 1},
_mcl_stairs = true,
})
--[[
mcl_copper.register_copper_variants("grate", {
register_copper_variants("grate", {
drawtype = "allfaces",
groups = {pickaxey = 2, building_block = 1, disable_suffocation = 1},
sunlight_propagates = true,
})
mcl_copper.register_copper_variants("chiseled", {
register_copper_variants("chiseled", {
groups = {pickaxey = 2, building_block = 1}
})
mcl_copper.register_copper_variants("bulb_off", {
register_copper_variants("bulb_off", {
groups = {pickaxey = 2, building_block = 1},
mesecons = {
effector = {
@ -251,7 +237,7 @@ mcl_copper.register_copper_variants("bulb_off", {
},
})
mcl_copper.register_copper_variants("bulb_on", {
register_copper_variants("bulb_on", {
drop = "bulb_off",
groups = {pickaxey = 2, building_block = 1, not_in_creative_inventory = 1},
light_source = 14,
@ -265,7 +251,7 @@ mcl_copper.register_copper_variants("bulb_on", {
paramtype = "light"
})
mcl_copper.register_copper_variants("bulb_powered_off", {
register_copper_variants("bulb_powered_off", {
drop = "bulb_off",
groups = {pickaxey = 2, building_block = 1, not_in_creative_inventory = 1},
mesecons = {
@ -277,7 +263,7 @@ mcl_copper.register_copper_variants("bulb_powered_off", {
}
})
mcl_copper.register_copper_variants("bulb_powered_on", {
register_copper_variants("bulb_powered_on", {
drop = "bulb_off",
groups = {pickaxey = 2, building_block = 1, not_in_creative_inventory = 1},
light_source = 14,