Cranks, shafts, and spruce trees.

This commit is contained in:
Signal 2026-05-09 16:01:10 -04:00
parent 4659a008ac
commit 9011835cf4
40 changed files with 1496 additions and 104 deletions

View file

@ -5,6 +5,7 @@ function ns.register_slab(def)
def._variants = nil
rgt.register_node(def._name.."_slab", extend(def, {
_base_node = def._name,
drawtype = "nodebox",
node_box = {
type = "fixed",
@ -49,6 +50,92 @@ function ns.update_stair(pos, basename, leaf)
end
end
local function get_connection_dirs(dir, variant, orientation)
if variant == "stair_inner" then
if orientation == "back" then
return dir:rotate(vector.new(0, math.pi, 0)), dir:rotate(vector.new(0, -math.pi /2, 0))
else
return dir:rotate(vector.new(0, math.pi /2, 0)), dir
end
elseif variant == "stair_outer" then
if orientation == "back" then
return dir:rotate(vector.new(0, math.pi /2, 0)), dir
else
return dir:rotate(vector.new(0, math.pi, 0)), dir:rotate(vector.new(0, -math.pi /2, 0))
end
elseif variant == "stair" then
return dir:rotate(vector.new(0, math.pi /2, 0)), dir:rotate(vector.new(0, -math.pi /2, 0))
end
return vector.zero(), vector.zero()
end
local function place_stair(s, p, pt)
local m = rgt.players[p:get_player_name()]
local def = s:get_definition()
local out = ItemStack(s)
local variant = def._variant
local param2
s:set_name(def._base_node.."_stair")
local invert = m.pointed_node.intersection_point.y -m.pointed_node.under.y > 0.5
local adjusted_yaw = (math.pi *2 -m.yaw) +(math.pi /4)
if adjusted_yaw > math.pi *2 then
adjusted_yaw = adjusted_yaw -(math.pi *2)
end
local yaw = math.floor(adjusted_yaw /(math.pi /2))
local dir = vector.new(yaw == 1 and 1 or yaw == 3 and -1 or 0, 0, yaw == 0 and 1 or yaw == 2 and -1 or 0)
local dir_left = dir:rotate(vector.new(0, -math.pi /2, 0))
local dir_right = dir_left:rotate(vector.new(0, math.pi /2, 0))
-- local obj = minetest.add_entity(pt.above +dir, "display")
-- obj:set_properties {
-- visual = "cube",
-- textures = {"rgt_glass.png^[multiply:#f99", "rgt_glass.png^[multiply:#f99", "rgt_glass.png^[multiply:#f99", "rgt_glass.png^[multiply:#f99", "rgt_glass.png^[multiply:#f99", "rgt_glass.png^[multiply:#f99"}
-- }
-- minetest.after(10, function() obj:remove() end)
local front = minetest.get_node(pt.above +dir)
local front_def = minetest.registered_nodes[front.name]
local back = minetest.get_node(pt.above -dir)
local back_def = minetest.registered_nodes[back.name]
local left = minetest.get_node(pt.above +dir_left)
local left_def = minetest.registered_nodes[left.name]
local right = minetest.get_node(pt.above +dir_right)
if (front_def._variant or "none"):find "stair" then
local front_dir = minetest.facedir_to_dir(front.param2)
local dir_a, dir_b = get_connection_dirs(front_dir, front_def._variant)
if dir_a == dir then
s:set_name(def._base_node.."_stair_outer")
param2 = minetest.dir_to_facedir(dir_left)
elseif dir_b == dir then
s:set_name(def._base_node.."_stair_outer")
param2 = minetest.dir_to_facedir(dir_right)
end
elseif (back_def._variant or "none"):find "stair" then
local back_dir = minetest.facedir_to_dir(back.param2)
local dir_a, dir_b = get_connection_dirs(back_dir, back_def._variant, "back")
if dir_a == dir then
s:set_name(def._base_node.."_stair_inner")
param2 = minetest.dir_to_facedir(dir_left)
elseif dir_b == dir then
s:set_name(def._base_node.."_stair_inner")
param2 = minetest.dir_to_facedir(dir_right)
end
end
local stack = minetest.item_place_node(s, p, pt, param2)
out:set_count(stack:get_count())
return out
end
function ns.register_stair(def)
def = table.copy(def)
def._variants = nil
@ -56,36 +143,75 @@ function ns.register_stair(def)
def.groups[def._name.."_stair"] = 1
rgt.register_node(def._name.."_stair", extend(table.copy(def), {
_base_node = def._name,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, 0, 0.5}, {-0.5, -0.5, 0, 0.5, 0.5, 0.5}}
fixed = {
{
-0.5, -0.5, -0.5,
0.5, 0, 0.5
},
{
-0.5, -0.5, 0,
0.5, 0.5, 0.5
},
}
},
paramtype = "light",
paramtype2 = "facedir",
_variant = "stair",
on_place = place_stair,
}))
rgt.register_node(def._name.."_stair_inner", extend(table.copy(def), {
_base_node = def._name,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, 0, 0.5}, {-0.5, -0.5, 0, 0.5, 0.5, 0.5}, {-0.5, -0.5, -0.5, 0, 0.5, 0.5}}
fixed = {
{
-0.5, -0.5, -0.5,
0.5, 0, 0.5
},
{
-0.5, -0.5, -0.5,
0, 0.5, 0.5
},
{
-0.5, -0.5, 0,
0.5, 0.5, 0.5
},
}
},
paramtype = "light",
paramtype2 = "facedir",
_variant = "stair_inner",
on_place = place_stair,
drop = def._name.."_stair",
}))
rgt.register_node(def._name.."_stair_outer", extend(def, {
_base_node = def._name,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, 0, 0.5}, {-0.5, -0.5, 0.5, 0, 0.5, 0}}
fixed = {
{
-0.5, -0.5, -0.5,
0.5, 0, 0.5
},
{
-0.5, -0.5, 0.5,
0, 0.5, 0
}
}
},
paramtype = "light",
paramtype2 = "facedir",
_variant = "stair_outer",
on_place = place_stair,
drop = def._name.."_stair",
}))
end