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 STAIR_NODE_BOX = {
type = "fixed", fixed = {
{ -0.5, -0.5, -0.5, 0.5, 0.0, 0.5 },
{ -0.5, 0.0, 0.0, 0.5, 0.5, 0.5 },
},
-- Properties that every non-full block we're adding should share.
local SHARED_NONFULL_PROPERTIES = {
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
}
local function do_the_cursed_thing(name, def)
local base_mod_name = name:gsub(":.*", "")
local base_name = name:gsub(".*:", "")
local function make_node_box(...) return { type = "fixed", fixed = { ... } } end
local STAIR_NODE_BOX = make_node_box({ -0.5, -0.5, -0.5, 0.5, 0.0, 0.5 },
{ -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 stair_def = nodecore.underride({
description = def.description .. " Stair",
local function do_the_cursed_thing(base_full_name, base_def)
base_def = base_def or minetest.registered_nodes[base_full_name]
paramtype = "light",
paramtype2 = "facedir",
local base_mod_name = base_full_name:gsub(":.*", "")
local base_node_name = base_full_name:gsub(".*:", "")
drawtype = "nodebox",
node_box = STAIR_NODE_BOX,
selection_box = STAIR_NODE_BOX,
local function register_node_variant(variant, node_box)
minetest.register_node(
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,
groups = { stair = 1 },
}, def)
tiles = { { name = base_def.tiles[1], align_style = "world" } },
node_box = node_box, selection_box = node_box,
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
local plank_name = "nc_woodwork:plank"
local plank_def = minetest.registered_nodes[plank_name]
do_the_cursed_thing(plank_name, plank_def)
do_the_cursed_thing("nc_woodwork:plank")

Loading…
Cancel
Save