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

@ -76,6 +76,7 @@ for i = 1, 3 do
tiles = {"rgt_grass_"..i..".png"},
groups = {attached_node = 3, dig_immediate = 3},
walkable = false,
buildable_to = true,
selection_box = {
type = "fixed",
fixed = {
@ -96,6 +97,7 @@ rgt.register_node("grass_tall_bottom", {
tiles = {"rgt_grass_tall.png^[verticalframe:2:1"},
groups = {attached_node = 3, dig_immediate = 3},
walkable = false,
buildable_to = true,
selection_box = {
type = "fixed",
fixed = {
@ -147,6 +149,7 @@ rgt.register_node("grass_tall_top", {
}
},
drop = "grass_tall_bottom",
buildable_to = true,
after_destruct = function(pos)
local below = pos:offset(0, -1, 0)
local nb = minetest.get_node(below)
@ -191,57 +194,7 @@ rgt.register_node("sand", {
groups = {dig_immediate = 3}
})
rgt.register_node("oak_log", {
tiles = {"rgt_oak_log_top.png", "rgt_oak_log_top.png", "rgt_oak_log_side.png"},
groups = {dig_immediate = 3},
paramtype2 = "facedir"
})
rgt.register_node("oak_leaves", {
drawtype = "allfaces",
tiles = {"rgt_oak_leaves.png"},
use_texture_alpha = "clip",
groups = {dig_immediate = 3},
})
rgt.register_node("oak_planks", {
tiles = {{name = "rgt_oak_planks.png", align_style = "world"}},
_variants = "all",
groups = {dig_immediate = 3},
})
rgt.register_node("dark_planks", {
tiles = {{name = "rgt_dark_planks.png", align_style = "world"}},
_variants = "all",
groups = {dig_immediate = 3},
})
rgt.register_node("spruce_planks", {
tiles = {{name = "rgt_spruce_planks.png", align_style = "world"}},
_variants = "all",
groups = {dig_immediate = 3},
})
rgt.register_node("acacia_planks", {
tiles = {{name = "rgt_acacia_planks.png", align_style = "world"}},
_variants = "all",
groups = {dig_immediate = 3},
})
rgt.register_node("redwood_planks", {
tiles = {{name = "rgt_redwood_planks.png", align_style = "world"}},
_variants = "all",
groups = {dig_immediate = 3},
})
rgt.register_node("birch_planks", {
tiles = {{name = "rgt_birch_planks.png", align_style = "world"}},
_variants = "all",
groups = {dig_immediate = 3},
})
include "wood.lua"
rgt.register_node("glass", {
drawtype = "glasslike",
@ -266,6 +219,19 @@ rgt.register_node("basalt", {
groups = {dig_immediate = 3},
})
rgt.register_node("basalt_tile", {
tiles = {{name = "rgt_basalt_tile.png", align_style = "world"}},
_variants = "all",
groups = {dig_immediate = 3},
})
rgt.register_node("basalt_brick_large", {
tiles = {{name = "rgt_basalt_brick_large.png", align_style = "world"}},
_variants = "all",
groups = {dig_immediate = 3},
})
rgt.register_node("water", {
tiles = {"[fill:16x16:0,0:#2d5a7c77^[fill:14x14:1,1:#2d5a7c33"},
@ -443,26 +409,26 @@ minetest.register_decoration {
fill_ratio = 0.2,
}
minetest.override_item("", {
on_place = function(s, p, pt)
if minetest.get_node(pt.under).name:find "dirt_grass" then
minetest.set_node(pt.under, {name = "path_grass"})
end
-- minetest.spawn_tree(pt.above, {
-- axiom = "TF[FFA]",
-- rules_a = "F",
-- trunk = "oak_log",
-- leaves = "oak_leaves",
-- angle = 30,
-- iterations = 2,
-- random_level = 0,
-- trunk_type = "single",
---- thin_branches = true,
-- fruit_chance = 0,
-- fruit = "stone_brick"
-- })
end
})
--minetest.override_item("", {
-- on_place = function(s, p, pt)
-- if minetest.get_node(pt.under).name:find "dirt_grass" then
-- minetest.set_node(pt.under, {name = "path_grass"})
-- end
---- minetest.spawn_tree(pt.above, {
---- axiom = "TF[FFA]",
---- rules_a = "F",
---- trunk = "oak_log",
---- leaves = "oak_leaves",
---- angle = 30,
---- iterations = 2,
---- random_level = 0,
---- trunk_type = "single",
------ thin_branches = true,
---- fruit_chance = 0,
---- fruit = "stone_brick"
---- })
-- end
--})
minetest.register_chatcommand("biome", {
func = function(name)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 272 B

After

Width:  |  Height:  |  Size: 320 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 B

After

Width:  |  Height:  |  Size: 214 B

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 277 B

After

Width:  |  Height:  |  Size: 316 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 263 B

After

Width:  |  Height:  |  Size: 293 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 272 B

After

Width:  |  Height:  |  Size: 313 B

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 272 B

After

Width:  |  Height:  |  Size: 306 B

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 420 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B

After

Width:  |  Height:  |  Size: 306 B

Before After
Before After

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

350
mods/rgt_world/wood.lua Normal file
View file

@ -0,0 +1,350 @@
-- MARK: Helpers
local fence_nodebox = {
type = "connected",
fixed = {
-2/16, -0.5, -2/16,
2/16, 0.5, 2/16
},
connect_front = {
{
-1/16, -6/16, -0.5,
1/16, -2/16, 0
},
{
-1/16, 2/16, -0.5,
1/16, 6/16, 0
}
},
connect_back = {
{
-1/16, -6/16, 0,
1/16, -2/16, 0.5
},
{
-1/16, 2/16, 0,
1/16, 6/16, 0.5
}
},
connect_left = {
{
-0.5, -6/16, -1/16,
0, -2/16, 1/16
},
{
-0.5, 2/16, -1/16,
0, 6/16, 1/16
}
},
connect_right = {
{
0, -6/16, -1/16,
0.5, -2/16, 1/16
},
{
0, 2/16, -1/16,
0.5, 6/16, 1/16
}
},
}
local fence_gate_nodebox = {
type = "fixed",
fixed = {
{
-8/16, -7/16, -1/16,
-6/16, 7/16, 1/16
},
{
8/16, -7/16, -1/16,
6/16, 7/16, 1/16
},
{
-6/16, -6/16, -1/16,
6/16, -2/16, 1/16
},
{
-6/16, 2/16, -1/16,
6/16, 6/16, 1/16
}
}
}
local fence_gate_open_nodebox = {
type = "fixed",
fixed = {
{
-8/16, -7/16, -1/16,
-6/16, 7/16, 1/16
},
{
8/16, -7/16, -1/16,
6/16, 7/16, 1/16
},
{
-8/16, -6/16, 1/16,
-6/16, -2/16, 0.5
},
{
-8/16, 2/16, 1/16,
-6/16, 6/16, 0.5
},
{
8/16, -6/16, 1/16,
6/16, -2/16, 0.5
},
{
8/16, 2/16, 1/16,
6/16, 6/16, 0.5
},
}
}
local ladder_nodebox = {
type = "fixed",
fixed = {
{
-7/16, -0.5, 0.5,
-5/16, 0.5, 6/16
},
{
5/16, -0.5, 0.5,
7/16, 0.5, 6/16
},
{
-5/16, -7/16, 7.5/16,
5/16, -5/16, 6.5/16
},
{
-5/16, -3/16, 7.5/16,
5/16, -1/16, 6.5/16
},
{
-5/16, 1/16, 7.5/16,
5/16, 3/16, 6.5/16
},
{
-5/16, 5/16, 7.5/16,
5/16, 7/16, 6.5/16
},
}
}
local log_nodebox = {
type = "fixed",
fixed = {
{
-6/16, -0.5, -0.5,
6/16, 0.5, 0.5,
},
{
-0.5, -0.5, -6/16,
0.5, 0.5, 6/16,
}
}
}
function rgt.register_fence(name, texture)
rgt.register_node(name.."_fence", {
drawtype = "nodebox",
node_box = fence_nodebox,
connects_to = {"group:fence"},
paramtype = "light",
sunlight_propagates = true,
tiles = {{name = texture or "rgt_"..name.."_planks.png", align_style = "world"}},
groups = {dig_immediate = 3, fence = 1},
})
local function fence_gate_swap(pos, node, p)
if node.name:find "fence_gate_open" then
node.name = node.name:gsub("fence_gate_open", "fence_gate")
elseif node.name:find "fence_gate" then
node.name = node.name:gsub("fence_gate", "fence_gate_open")
local rot = minetest.fourdir_to_dir(node.param2)
-- Get the axis on which the gate will open.
local axis = rot.x ~= 0 and "x" or "z"
local dir = p:get_pos():direction(pos)
-- If the gate will open in the opposite direction from the player's facing direction, flip it.
if math.sign(dir[axis]) ~= math.sign(rot[axis]) then
node.param2 = (node.param2 +2) %4
end
end
minetest.swap_node(pos, node)
end
rgt.register_node(name.."_fence_gate", {
drawtype = "nodebox",
node_box = fence_gate_nodebox,
connects_to = {"group:fence"},
connect_sides = {"left", "right"},
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "4dir",
tiles = {{name = "rgt_"..name.."_planks.png", align_style = "world"}},
groups = {dig_immediate = 3, fence = 1},
on_rightclick = fence_gate_swap,
})
rgt.register_node(name.."_fence_gate_open", {
drawtype = "nodebox",
node_box = fence_gate_open_nodebox,
connects_to = {"group:fence"},
connect_sides = {"left", "right"},
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "4dir",
tiles = {{name = "rgt_"..name.."_planks.png", align_style = "world"}},
groups = {dig_immediate = 3, fence = 1},
on_rightclick = fence_gate_swap,
})
end
function rgt.register_ladder(name)
rgt.register_node(name.."_ladder", {
drawtype = "nodebox",
node_box = ladder_nodebox,
selection_box = {
type = "fixed",
fixed = {-7/16, -0.5, 0.5, 7/16, 0.5, 6/16}
},
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "4dir",
climbable = true,
tiles = {{name = "rgt_"..name.."_planks.png", align_style = "world"}},
groups = {dig_immediate = 3, ladder = 1},
on_place = function(s, p, pt)
local under = minetest.get_node(pt.under)
-- If placing a ladder against a ladder, attempt to extend the pointed ladder rather than naively placing against it.
if under.name:find "ladder" then
local old_pt = table.copy(pt)
-- This will blow up for touchscreen users, but there's no way around it because they don't obey crosshair restrictions.
local iy = rgt.players[p:get_player_name()].pointed_node
-- `iy` can be nil in edge cases where the client clicked the node momentarily but is no longer pointing at the
-- node on the server when the message arrives and the server responds. In these cases, we just don't place anything
-- because we cannot determine the direction in which the player wishes to extend the ladder.
if not iy then return end
iy = iy.intersection_point.y
-- Try extending in the pointed direction first.
pt.above = pt.under:offset(0, iy -pt.under.y > 0 and 1 or -1, 0)
local s, success = minetest.item_place_node(s, p, pt, under.param2)
if success then return s end
-- If we can't, try extending in the other direction.
pt.above = pt.under:offset(0, iy -pt.under.y > 0 and -1 or 1, 0)
s, success = minetest.item_place_node(s, p, pt, under.param2)
if success then return s end
-- If that too fails, don't place anything. We could fall back to default placement, but that would make rapid laddering more annoying.
else
return minetest.item_place_node(s, p, pt)
end
end
})
end
-- MARK: Oak
rgt.register_node("oak_log", {
drawtype = "nodebox",
node_box = log_nodebox,
tiles = {"rgt_oak_log_top.png", "rgt_oak_log_top.png", "rgt_oak_log_side.png"},
groups = {dig_immediate = 3},
paramtype2 = "facedir",
})
rgt.register_node("oak_leaves", {
drawtype = "allfaces",
tiles = {"rgt_oak_leaves.png"},
use_texture_alpha = "clip",
groups = {dig_immediate = 3},
})
rgt.register_node("oak_planks", {
tiles = {{name = "rgt_oak_planks.png", align_style = "world"}},
_variants = "all",
groups = {dig_immediate = 3},
})
rgt.register_fence("oak")
rgt.register_ladder("oak")
-- MARK: Dark
rgt.register_node("dark_planks", {
tiles = {{name = "rgt_dark_planks.png", align_style = "world"}},
_variants = "all",
groups = {dig_immediate = 3},
})
rgt.register_fence("dark")
rgt.register_ladder("dark")
-- MARK: Spruce
rgt.register_node("spruce_log", {
drawtype = "nodebox",
node_box = log_nodebox,
tiles = {"rgt_spruce_log_top.png", "rgt_spruce_log_top.png", "rgt_spruce_log_side.png"},
groups = {dig_immediate = 3},
paramtype2 = "facedir",
})
rgt.register_node("spruce_planks", {
tiles = {{name = "rgt_spruce_planks.png", align_style = "world"}},
_variants = "all",
groups = {dig_immediate = 3},
})
rgt.register_node("spruce_leaves", {
drawtype = "allfaces",
tiles = {"rgt_spruce_leaves.png"},
use_texture_alpha = "clip",
groups = {dig_immediate = 3},
})
rgt.register_fence("spruce")
rgt.register_ladder("spruce")
-- MARK: Acacia
rgt.register_node("acacia_planks", {
tiles = {{name = "rgt_acacia_planks.png", align_style = "world"}},
_variants = "all",
groups = {dig_immediate = 3},
})
rgt.register_fence("acacia")
rgt.register_ladder("acacia")
-- MARK: Redwood
rgt.register_node("redwood_planks", {
tiles = {{name = "rgt_redwood_planks.png", align_style = "world"}},
_variants = "all",
groups = {dig_immediate = 3},
})
rgt.register_fence("redwood")
rgt.register_ladder("redwood")
-- MARK: Birch
rgt.register_node("birch_planks", {
tiles = {{name = "rgt_birch_planks.png", align_style = "world"}},
_variants = "all",
groups = {dig_immediate = 3},
})
rgt.register_fence("birch")
rgt.register_ladder("birch")