From 62037ad60aaf337f959904e800cd3396ffea9c10 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Sat, 4 Jan 2025 19:50:33 +0100 Subject: [PATCH] improve octagon glass pane slope / refactor node- and selectionbox code --- common.lua | 10 +++--- models.lua | 4 +-- models/scifi_nodes_slope_simple.obj | 12 +++++++ octagon_glass.lua | 20 ------------ octagon_panes.lua | 50 ++++++++++++++++++++++++----- 5 files changed, 61 insertions(+), 35 deletions(-) create mode 100644 models/scifi_nodes_slope_simple.obj diff --git a/common.lua b/common.lua index 9ea769a..13dfe8e 100644 --- a/common.lua +++ b/common.lua @@ -19,7 +19,7 @@ function scifi_nodes.get_switch_rules(param2) return rules end -scifi_nodes.slope_selection_box = { +scifi_nodes.slope_box = { type = "fixed", fixed = { {-0.5, -0.5, -0.5, 0.5, -0.25, 0.5}, @@ -29,12 +29,12 @@ scifi_nodes.slope_selection_box = { } } -scifi_nodes.slope_collision_box = { +scifi_nodes.slope_box_simple = { type = "fixed", fixed = { - {-0.5, -0.5, -0.5, 0.5, -0.25, 0.5}, - {-0.5, -0.25, -0.25, 0.5, 0, 0.5}, - {-0.5, 0, 0, 0.5, 0.25, 0.5}, + {-0.5, -0.5, -0.5, 0.5, -0.25, -0.25}, + {-0.5, -0.25, -0.25, 0.5, 0, 0}, + {-0.5, 0, 0, 0.5, 0.25, 0.25}, {-0.5, 0.25, 0.25, 0.5, 0.5, 0.5} } } diff --git a/models.lua b/models.lua index 54e68dd..253f27c 100644 --- a/models.lua +++ b/models.lua @@ -16,8 +16,8 @@ function scifi_nodes.register_slope(name, desc, texture, light, soundtype) drawtype = "mesh", mesh = "scifi_nodes_slope.obj", tiles = texture, - selection_box = scifi_nodes.slope_selection_box, - collision_box = scifi_nodes.slope_collision_box, + selection_box = scifi_nodes.slope_box, + collision_box = scifi_nodes.slope_box, paramtype = "light", paramtype2 = "facedir", use_texture_alpha = "clip", diff --git a/models/scifi_nodes_slope_simple.obj b/models/scifi_nodes_slope_simple.obj new file mode 100644 index 0000000..d93373e --- /dev/null +++ b/models/scifi_nodes_slope_simple.obj @@ -0,0 +1,12 @@ +g top +v 0.500000 0.500000 0.500000 +v -0.500000 0.500000 0.500000 +v -0.500000 -0.500000 -0.500000 +v 0.500000 -0.500000 -0.500000 +vt 1.0000 1.0000 +vt 0.0000 1.0000 +vt 0.0000 0.0000 +vt 1.0000 0.0000 +vn 0.0000 0.7071 -0.7071 +s off +f 2/1/1 1/2/1 4/3/1 3/4/1 \ No newline at end of file diff --git a/octagon_glass.lua b/octagon_glass.lua index a9ced5f..9580029 100644 --- a/octagon_glass.lua +++ b/octagon_glass.lua @@ -19,26 +19,6 @@ local function register_glass(key, name) is_ground_content = false, sounds = scifi_nodes.node_sound_glass_defaults(), }) - - minetest.register_node("scifi_nodes:" .. key .. "_slope", { - description = "Octagon Glass slope", - sunlight_propagates = true, - drawtype = "mesh", - mesh = "scifi_nodes_slope.obj", - tiles = tiles, - paramtype = "light", - paramtype2 = "facedir", - use_texture_alpha = "blend", - light_source = 10, - groups = { - cracky = 2, - dig_generic = 3 - }, - selection_box = scifi_nodes.slope_selection_box, - collision_box = scifi_nodes.slope_collision_box, - is_ground_content = false, - sounds = scifi_nodes.node_sound_glass_defaults() - }) end register_glass("octppl", "Purple") diff --git a/octagon_panes.lua b/octagon_panes.lua index 82de190..6a81ecc 100644 --- a/octagon_panes.lua +++ b/octagon_panes.lua @@ -1,13 +1,15 @@ -local function register(basename, description, texture) +local function register(basename, color, texture) local nodename_single = "scifi_nodes:" .. basename .. "_pane" local nodename_double = "scifi_nodes:" .. basename .. "_pane_double" local nodename_offset = "scifi_nodes:" .. basename .. "_pane_offset" + local nodename_slope = "scifi_nodes:" .. basename .. "_slope" local recipe_ingredient = "scifi_nodes:" .. basename + local base_decription = color .. " octagon glass" -- single height minetest.register_node(nodename_single, { - description = description, + description = base_decription .. " pane", drawtype = "nodebox", tiles = { texture @@ -35,7 +37,7 @@ local function register(basename, description, texture) -- double height minetest.register_node(nodename_double, { - description = description, + description = base_decription .. " pane (double)", drawtype = "nodebox", tiles = { texture @@ -63,7 +65,7 @@ local function register(basename, description, texture) -- single height with offset minetest.register_node(nodename_offset, { - description = description, + description = base_decription .. " pane (offset)", drawtype = "nodebox", tiles = { texture @@ -90,6 +92,28 @@ local function register(basename, description, texture) sounds = scifi_nodes.node_sound_glass_defaults() }) + -- slope pane + minetest.register_node(nodename_slope, { + description = base_decription .. " pane (slope)", + sunlight_propagates = true, + drawtype = "mesh", + mesh = "scifi_nodes_slope_simple.obj", + tiles = { + texture + }, + paramtype = "light", + paramtype2 = "facedir", + use_texture_alpha = "blend", + light_source = 10, + groups = { + cracky = 2, + dig_generic = 3 + }, + selection_box = scifi_nodes.slope_box_simple, + collision_box = scifi_nodes.slope_box_simple, + is_ground_content = false, + sounds = scifi_nodes.node_sound_glass_defaults() + }) -- register recipes minetest.register_craft({ @@ -99,6 +123,15 @@ local function register(basename, description, texture) }, }) + minetest.register_craft({ + output = nodename_slope .. " 16", + recipe = { + {"", "", recipe_ingredient}, + {"", recipe_ingredient, ""}, + {recipe_ingredient, "", ""} + }, + }) + minetest.register_craft({ output = nodename_double .. " 16", recipe = { @@ -114,8 +147,9 @@ local function register(basename, description, texture) }) end -register("octrng", "Orange Octagon Glass pane", "scifi_nodes_octrng.png") -register("octgrn", "Green Octagon Glass pane", "scifi_nodes_octgrn.png") -register("octbl", "Blue Octagon Glass pane", "scifi_nodes_octbl.png") -register("octppl", "Purple Octagon Glass pane", "scifi_nodes_octppl.png") +register("octrng", "Orange", "scifi_nodes_octrng.png") +register("octgrn", "Green", "scifi_nodes_octgrn.png") +register("octbl", "Blue", "scifi_nodes_octbl.png") +register("octppl", "Purple", "scifi_nodes_octppl.png") +register("octwht", "White", "scifi_nodes_octwht.png") register("glass", "Dark Glass pane", "scifi_nodes_glass.png")