From e976c81cec879019db91920d0463e81dfb843060 Mon Sep 17 00:00:00 2001 From: Doloment Date: Tue, 28 May 2024 00:50:12 +0700 Subject: [PATCH] Add rock bricks+blocks; move chamotte and mordor bricks+blocks into separate files; save untranslated definition for rocks to use it in other blocks registration. Closes #1304 --- .../Blocks/lord_bricks/chamotte_bricks.lua | 94 +++++++++++++++++++ mods/lord/Blocks/lord_bricks/init.lua | 26 +---- mods/lord/Blocks/lord_bricks/mod.conf | 2 +- .../{nodes.lua => mordor_bricks.lua} | 83 ++-------------- mods/lord/Blocks/lord_bricks/rock_bricks.lua | 51 ++++++++++ mods/lord/Blocks/lord_rocks/src/rocks/api.lua | 10 +- mods/lord/Blocks/lord_walls/init.lua | 2 +- 7 files changed, 165 insertions(+), 103 deletions(-) create mode 100644 mods/lord/Blocks/lord_bricks/chamotte_bricks.lua rename mods/lord/Blocks/lord_bricks/{nodes.lua => mordor_bricks.lua} (51%) create mode 100644 mods/lord/Blocks/lord_bricks/rock_bricks.lua diff --git a/mods/lord/Blocks/lord_bricks/chamotte_bricks.lua b/mods/lord/Blocks/lord_bricks/chamotte_bricks.lua new file mode 100644 index 000000000..d70f1d6c4 --- /dev/null +++ b/mods/lord/Blocks/lord_bricks/chamotte_bricks.lua @@ -0,0 +1,94 @@ +local S = minetest.get_translator(minetest.get_current_modname()) + +-- Items + +minetest.register_craftitem("lord_bricks:chamotte_brick_raw", { + description = S("Raw Chamotte Brick"), + inventory_image = "lord_bricks_chamotte_brick_raw.png" +}) + +minetest.register_craftitem("lord_bricks:chamotte_brick_dried", { + description = S("Chamotte Brick"), + inventory_image = "lord_bricks_chamotte_brick_dried.png" +}) + + +-- Nodes + +minetest.register_node("lord_bricks:chamotte_masonry", { + description = S("Chamotte Masonry"), + tiles = {"lord_bricks_chamotte_masonry.png"}, + is_ground_content = false, + groups = {cracky = 2, brick = 1}, + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("lord_bricks:chamotte_masonry_large", { + description = S("Large Chamotte Masonry"), + tiles = {"lord_bricks_chamotte_masonry_large.png"}, + is_ground_content = false, + groups = {cracky = 2, brick = 1}, + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("lord_bricks:chamotte_brick", { + description = S("Chamotte Brick"), + tiles = {"lord_bricks_chamotte_brick.png"}, + is_ground_content = false, + groups = {cracky = 2, brick = 1}, + sounds = default.node_sound_stone_defaults(), +}) + +minetest.register_node("lord_bricks:chamotte_block", { + description = S("Chamotte Block"), + tiles = {"lord_bricks_chamotte_block.png"}, + is_ground_content = false, + groups = {cracky = 2}, + sounds = default.node_sound_stone_defaults(), +}) + + +stairs.register_stair_and_slab("chamotte_masonry", "lord_bricks:chamotte_masonry", + {cracky=2}, + {"lord_bricks_chamotte_masonry.png"}, + S("Chamotte Masonry Stair"), + S("Chamotte Masonry Slab"), + default.node_sound_stone_defaults(), + false, + S("Inner Chamotte Masonry Stair"), + S("Outer Chamotte Masonry Stair") +) + +stairs.register_stair_and_slab("chamotte_masonry_large", "lord_bricks:chamotte_masonry_large", + {cracky=2}, + {"lord_bricks_chamotte_masonry_large.png"}, + S("Large Chamotte Masonry Stair"), + S("Large Chamotte Masonry Slab"), + default.node_sound_stone_defaults(), + false, + S("Inner Large Chamotte Masonry Stair"), + S("Outer Large Chamotte Masonry Stair") +) + +stairs.register_stair_and_slab("chamotte_brick", "lord_bricks:chamotte_brick", + {cracky=2}, + {"lord_bricks_chamotte_brick.png"}, + S("Chamotte Brick Stair"), + S("Chamotte Brick Slab"), + default.node_sound_stone_defaults(), + false, + S("Inner Chamotte Brick Stair"), + S("Outer Chamotte Brick Stair") +) + +stairs.register_stair_and_slab("chamotte_block", "lord_bricks:chamotte_block", + {cracky=2}, + {"lord_bricks_chamotte_block.png"}, + S("Chamotte Block Stair"), + S("Chamotte Block Slab"), + default.node_sound_stone_defaults(), + false, + S("Inner Chamotte Block Stair"), + S("Outer Chamotte Block Stair") +) + diff --git a/mods/lord/Blocks/lord_bricks/init.lua b/mods/lord/Blocks/lord_bricks/init.lua index 3dc635e0b..1852d18d7 100644 --- a/mods/lord/Blocks/lord_bricks/init.lua +++ b/mods/lord/Blocks/lord_bricks/init.lua @@ -1,7 +1,10 @@ local S = minetest.get_translator(minetest.get_current_modname()) dofile(minetest.get_modpath(minetest.get_current_modname()).."/crafts.lua") -dofile(minetest.get_modpath(minetest.get_current_modname()).."/nodes.lua") +dofile(minetest.get_modpath(minetest.get_current_modname()).."/chamotte_bricks.lua") +dofile(minetest.get_modpath(minetest.get_current_modname()).."/mordor_bricks.lua") +dofile(minetest.get_modpath(minetest.get_current_modname()).."/rock_bricks.lua") + -- Raw Brick for default clay @@ -10,24 +13,3 @@ minetest.register_craftitem("lord_bricks:clay_brick_raw", { inventory_image = "lord_bricks_clay_brick_raw.png" }) --- Chamotte Brick -minetest.register_craftitem("lord_bricks:chamotte_brick_raw", { - description = S("Raw Chamotte Brick"), - inventory_image = "lord_bricks_chamotte_brick_raw.png" -}) - -minetest.register_craftitem("lord_bricks:chamotte_brick_dried", { - description = S("Chamotte Brick"), - inventory_image = "lord_bricks_chamotte_brick_dried.png" -}) - --- Mordor Clay Brick -minetest.register_craftitem("lord_bricks:mordor_clay_brick_raw", { - description = S("Raw Mordor Clay Brick"), - inventory_image = "lord_bricks_mordor_clay_brick_raw.png" -}) - -minetest.register_craftitem("lord_bricks:mordor_clay_brick_dried", { - description = S("Mordor Clay Brick"), - inventory_image = "lord_bricks_mordor_clay_brick_dried.png" -}) diff --git a/mods/lord/Blocks/lord_bricks/mod.conf b/mods/lord/Blocks/lord_bricks/mod.conf index 8525a5b98..c8ecfd7ff 100644 --- a/mods/lord/Blocks/lord_bricks/mod.conf +++ b/mods/lord/Blocks/lord_bricks/mod.conf @@ -1,2 +1,2 @@ name = lord_bricks -depends = lord_overwrites_mtg_default, stairs +depends = lord_overwrites_mtg_default, stairs, lord_rocks diff --git a/mods/lord/Blocks/lord_bricks/nodes.lua b/mods/lord/Blocks/lord_bricks/mordor_bricks.lua similarity index 51% rename from mods/lord/Blocks/lord_bricks/nodes.lua rename to mods/lord/Blocks/lord_bricks/mordor_bricks.lua index eced675b2..8a7fc8000 100644 --- a/mods/lord/Blocks/lord_bricks/nodes.lua +++ b/mods/lord/Blocks/lord_bricks/mordor_bricks.lua @@ -1,86 +1,19 @@ local S = minetest.get_translator(minetest.get_current_modname()) --- Chamotte Bricks +-- Items -minetest.register_node("lord_bricks:chamotte_masonry", { - description = S("Chamotte Masonry"), - tiles = {"lord_bricks_chamotte_masonry.png"}, - is_ground_content = false, - groups = {cracky = 2, brick = 1}, - sounds = default.node_sound_stone_defaults(), -}) - -minetest.register_node("lord_bricks:chamotte_masonry_large", { - description = S("Large Chamotte Masonry"), - tiles = {"lord_bricks_chamotte_masonry_large.png"}, - is_ground_content = false, - groups = {cracky = 2, brick = 1}, - sounds = default.node_sound_stone_defaults(), +minetest.register_craftitem("lord_bricks:mordor_clay_brick_raw", { + description = S("Raw Mordor Clay Brick"), + inventory_image = "lord_bricks_mordor_clay_brick_raw.png" }) -minetest.register_node("lord_bricks:chamotte_brick", { - description = S("Chamotte Brick"), - tiles = {"lord_bricks_chamotte_brick.png"}, - is_ground_content = false, - groups = {cracky = 2, brick = 1}, - sounds = default.node_sound_stone_defaults(), -}) - -minetest.register_node("lord_bricks:chamotte_block", { - description = S("Chamotte Block"), - tiles = {"lord_bricks_chamotte_block.png"}, - is_ground_content = false, - groups = {cracky = 2}, - sounds = default.node_sound_stone_defaults(), +minetest.register_craftitem("lord_bricks:mordor_clay_brick_dried", { + description = S("Mordor Clay Brick"), + inventory_image = "lord_bricks_mordor_clay_brick_dried.png" }) -stairs.register_stair_and_slab("chamotte_masonry", "lord_bricks:chamotte_masonry", - {cracky=2}, - {"lord_bricks_chamotte_masonry.png"}, - S("Chamotte Masonry Stair"), - S("Chamotte Masonry Slab"), - default.node_sound_stone_defaults(), - false, - S("Inner Chamotte Masonry Stair"), - S("Outer Chamotte Masonry Stair") -) - -stairs.register_stair_and_slab("chamotte_masonry_large", "lord_bricks:chamotte_masonry_large", - {cracky=2}, - {"lord_bricks_chamotte_masonry_large.png"}, - S("Large Chamotte Masonry Stair"), - S("Large Chamotte Masonry Slab"), - default.node_sound_stone_defaults(), - false, - S("Inner Large Chamotte Masonry Stair"), - S("Outer Large Chamotte Masonry Stair") -) - -stairs.register_stair_and_slab("chamotte_brick", "lord_bricks:chamotte_brick", - {cracky=2}, - {"lord_bricks_chamotte_brick.png"}, - S("Chamotte Brick Stair"), - S("Chamotte Brick Slab"), - default.node_sound_stone_defaults(), - false, - S("Inner Chamotte Brick Stair"), - S("Outer Chamotte Brick Stair") -) - -stairs.register_stair_and_slab("chamotte_block", "lord_bricks:chamotte_block", - {cracky=2}, - {"lord_bricks_chamotte_block.png"}, - S("Chamotte Block Stair"), - S("Chamotte Block Slab"), - default.node_sound_stone_defaults(), - false, - S("Inner Chamotte Block Stair"), - S("Outer Chamotte Block Stair") -) - - --- Mordor Clay Bricks +-- Nodes minetest.register_node("lord_bricks:mordor_clay_masonry", { description = S("Mordor Clay Masonry"), diff --git a/mods/lord/Blocks/lord_bricks/rock_bricks.lua b/mods/lord/Blocks/lord_bricks/rock_bricks.lua new file mode 100644 index 000000000..460867003 --- /dev/null +++ b/mods/lord/Blocks/lord_bricks/rock_bricks.lua @@ -0,0 +1,51 @@ +local S = minetest.get_translator(minetest.get_current_modname()) + +for node_name, registration in pairs(rocks.get_lord_nodes()) do + local name = node_name:split(":")[2] + local base_description = registration.original_description + + local def_brick = table.copy(minetest.registered_nodes[node_name]) + local brick_name = string.format("lord_bricks:%s_brick", name) + def_brick.description = S(string.format("%s Brick", base_description)) + def_brick.tiles = { string.format("lord_bricks_$s_brick.png", name) } + def_brick.groups.stone = nil + def_brick.groups.rock = nil + def_brick.groups.brick = 1 + + local def_block = table.copy(minetest.registered_nodes[node_name]) + local block_name = string.format("lord_bricks:%s_block", name) + def_block.description = S(string.format("%s Block", base_description)) + def_brick.tiles = { string.format("lord_bricks_$s_block.png", name) } + def_block.groups.stone = nil + def_block.groups.rock = nil + + for _, texture in ipairs(def_brick.tiles) do + minetest.log("info", "use texture: " .. texture .. " at " .. __FILE_LINE__()) + end + + for _, texture in ipairs(def_block.tiles) do + minetest.log("info", "use texture: " .. texture .. " at " .. __FILE_LINE__()) + end + + minetest.register_node(brick_name, def_brick) + minetest.register_node(block_name, def_block) + + minetest.register_craft({ + type = "shaped", + output = brick_name .. " 4", + recipe = { + { node_name, node_name, }, + { node_name, node_name, }, + }, + }) + + minetest.register_craft({ + type = "shaped", + output = block_name .. " 9", + recipe = { + { node_name, node_name, node_name, }, + { node_name, node_name, node_name, }, + { node_name, node_name, node_name, }, + }, + }) +end diff --git a/mods/lord/Blocks/lord_rocks/src/rocks/api.lua b/mods/lord/Blocks/lord_rocks/src/rocks/api.lua index 4a12f874b..b34220e68 100644 --- a/mods/lord/Blocks/lord_rocks/src/rocks/api.lua +++ b/mods/lord/Blocks/lord_rocks/src/rocks/api.lua @@ -64,13 +64,15 @@ local function register_rock(node_name, softness, definition, register_stairs) end rocks.nodes[node_name] = { - softness = softness, - definition = definition, + softness = softness, + definition = definition, + original_description = description } rocks.lord_nodes[node_name] = { - softness = softness, - definition = definition, + softness = softness, + definition = definition, + original_description = description } diff --git a/mods/lord/Blocks/lord_walls/init.lua b/mods/lord/Blocks/lord_walls/init.lua index 61ee4dd74..c8b0588c6 100644 --- a/mods/lord/Blocks/lord_walls/init.lua +++ b/mods/lord/Blocks/lord_walls/init.lua @@ -27,7 +27,7 @@ for node_name, registration in pairs(rocks.get_lord_nodes()) do local sub_name = node_name:split(":")[2] local walls_node = ":walls:" .. sub_name - local description = sub_name:remove_underscores():to_headline() + local description = registration.original_description local texture = registration.definition.tiles walls.register(walls_node, S(description), texture, node_name, default.node_sound_stone_defaults())