Restructuring, slabs and steps

main
copygirl 1 year ago
parent 6051230af4
commit 43a8414d82
  1. 55
      init.lua

@ -3,35 +3,44 @@ local minetest, nodecore
local MOD_NAME = minetest.get_current_modname() local MOD_NAME = minetest.get_current_modname()
local STAIR_NODE_BOX = { -- Properties that every non-full block we're adding should share.
type = "fixed", fixed = { local SHARED_NONFULL_PROPERTIES = {
{ -0.5, -0.5, -0.5, 0.5, 0.0, 0.5 }, drawtype = "nodebox",
{ -0.5, 0.0, 0.0, 0.5, 0.5, 0.5 }, paramtype = "light",
}, paramtype2 = "facedir",
sunlight_propagates = true,
} }
local function do_the_cursed_thing(name, def) local function make_node_box(...) return { type = "fixed", fixed = { ... } } end
local base_mod_name = name:gsub(":.*", "") local STAIR_NODE_BOX = make_node_box({ -0.5, -0.5, -0.5, 0.5, 0.0, 0.5 },
local base_name = name:gsub(".*:", "") { -0.5, 0.0, 0.0, 0.5, 0.5, 0.5 })
local SLAB_NODE_BOX = make_node_box({ -0.5, -0.5, -0.5, 0.5, 0.0, 0.5 })
local STEP_NODE_BOX = make_node_box({ -0.5, -0.5, 0.0, 0.5, 0.0, 0.5 })
local stair_name = MOD_NAME .. ":" .. base_mod_name .. "__" .. base_name .. "_stair" local function do_the_cursed_thing(base_full_name, base_def)
local stair_def = nodecore.underride({ base_def = base_def or minetest.registered_nodes[base_full_name]
description = def.description .. " Stair",
paramtype = "light", local base_mod_name = base_full_name:gsub(":.*", "")
paramtype2 = "facedir", local base_node_name = base_full_name:gsub(".*:", "")
drawtype = "nodebox", local function register_node_variant(variant, node_box)
node_box = STAIR_NODE_BOX, minetest.register_node(
selection_box = STAIR_NODE_BOX, MOD_NAME .. ":" .. base_mod_name .. "__" .. base_node_name .. "_" .. variant:lower(),
nodecore.underride({
description = base_def.description .. " " .. variant,
groups = { [MOD_NAME .. ":" .. variant:lower()] = 1 },
sunlight_propagates = true, tiles = { { name = base_def.tiles[1], align_style = "world" } },
groups = { stair = 1 }, node_box = node_box, selection_box = node_box,
}, def)
drop = base_def.drop or base_full_name,
silktouch_as = base_def.silktouch_as or base_full_name,
}, SHARED_NONFULL_PROPERTIES, base_def))
end
minetest.register_node(stair_name, stair_def) register_node_variant("Stair", STAIR_NODE_BOX)
register_node_variant("Slab" , SLAB_NODE_BOX)
register_node_variant("Step" , STEP_NODE_BOX)
end end
local plank_name = "nc_woodwork:plank" do_the_cursed_thing("nc_woodwork:plank")
local plank_def = minetest.registered_nodes[plank_name]
do_the_cursed_thing(plank_name, plank_def)

Loading…
Cancel
Save