110 lines
3 KiB
Lua
110 lines
3 KiB
Lua
-- Vox Structural System
|
|
|
|
local structural_shapes = {}
|
|
|
|
-- Register a new structural shape
|
|
function vox_structural.register_shape(shape_name, shape_def)
|
|
structural_shapes[shape_name] = shape_def
|
|
end
|
|
|
|
-- Register a block with structural shapes
|
|
function vox_structural.register_block_with_shapes(modname, base_block, options)
|
|
for shape_name, shape_def in pairs(structural_shapes) do
|
|
local base_node_name = modname .. ":" .. base_block
|
|
local shape_node_name = modname .. ":" .. base_block .. "_" .. shape_name
|
|
|
|
-- Create the new node definition
|
|
local new_node_def = table.copy(minetest.registered_nodes[base_node_name])
|
|
new_node_def.description = new_node_def.description .. " (" .. shape_name:gsub("_", " ") .. ")"
|
|
new_node_def.tiles = shape_def.tiles or new_node_def.tiles
|
|
new_node_def.groups = table.copy(new_node_def.groups or {})
|
|
new_node_def.groups.shape = 1 -- Add a "shape" group
|
|
|
|
-- Apply shape-specific overrides
|
|
if shape_def.override then
|
|
for key, value in pairs(shape_def.override) do
|
|
new_node_def[key] = value
|
|
end
|
|
end
|
|
|
|
-- Register the new node
|
|
minetest.register_node(shape_node_name, new_node_def)
|
|
end
|
|
end
|
|
|
|
-- ---------------------------- Basic Shapes -------------------------- --
|
|
-- Slab
|
|
vox_structural.register_shape("slab", {
|
|
tiles = nil, -- Inherit tiles from the base block
|
|
override = {
|
|
drawtype = "nodebox",
|
|
node_box = {
|
|
type = "fixed",
|
|
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
|
|
},
|
|
},
|
|
})
|
|
|
|
-- Stairs
|
|
vox_structural.register_shape("stairs", {
|
|
tiles = nil,
|
|
override = {
|
|
drawtype = "nodebox",
|
|
node_box = {
|
|
type = "fixed",
|
|
fixed = {
|
|
{-0.5, -0.5, -0.5, 0.5, 0, 0.5},
|
|
{-0.5, 0, -0.5, 0.5, 0.5, 0},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
-- ---------------------------- Functional -------------------------- --
|
|
-- Pressure Plate
|
|
vox_structural.register_shape("pressure_plate", {
|
|
tiles = nil,
|
|
override = {
|
|
drawtype = "nodebox",
|
|
node_box = {
|
|
type = "fixed",
|
|
fixed = {
|
|
{-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
-- Button
|
|
|
|
-- Post
|
|
|
|
|
|
-- ------------------
|
|
-- Register door shapes with variants
|
|
vox_structural.register_shape("door_flush", {
|
|
override = {
|
|
drawtype = "mesh",
|
|
mesh = "door_flush.obj",
|
|
},
|
|
})
|
|
|
|
vox_structural.register_shape("door_half_window", {
|
|
override = {
|
|
drawtype = "mesh",
|
|
mesh = "door_half_window.obj",
|
|
},
|
|
})
|
|
|
|
-- Add mix-and-match for window materials
|
|
local window_variants = {"glass", "colored_glass", "paper", "colored_paper"}
|
|
|
|
for _, material in ipairs(window_variants) do
|
|
vox_structural.register_shape("door_half_window_" .. material, {
|
|
override = {
|
|
drawtype = "mesh",
|
|
mesh = "door_half_window.obj",
|
|
tiles = {"window_" .. material .. ".png"},
|
|
},
|
|
})
|
|
end
|