mirror of
https://github.com/mt-mods/homedecor_modpack.git
synced 2024-12-23 00:20:17 +01:00
add placeholders as not-buildable_to nodes, that can be set to prevent other nodes to build or expanded into expansions
this fixes #292
This commit is contained in:
parent
26a874d919
commit
fb1b620316
@ -23,6 +23,19 @@ homedecor.fdir_to_fwd = {
|
||||
{ -1, 0 },
|
||||
}
|
||||
|
||||
local placeholder_node = "homedecor:expansion_placeholder"
|
||||
minetest.register_node(placeholder_node, {
|
||||
description = "Expansion placeholder (you hacker you!)",
|
||||
groups = { not_in_creative_inventory=1 },
|
||||
drawtype = "airlike",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
selection_box = { type = "fixed", fixed = { 0, 0, 0, 0, 0, 0 } },
|
||||
is_ground_content = false,
|
||||
sunlight_propagates = true,
|
||||
buildable_to = false,
|
||||
})
|
||||
|
||||
-- selects which node was pointed at based on it being known, and either clickable or buildable_to
|
||||
local function select_node(pointed_thing)
|
||||
local pos = pointed_thing.under
|
||||
@ -52,7 +65,13 @@ local function stack(itemstack, placer, fdir, pos, def, pos2, node1, node2)
|
||||
local fdir = fdir or minetest.dir_to_facedir(placer:get_look_dir())
|
||||
minetest.set_node(pos, { name = node1, param2 = fdir })
|
||||
node2 = node2 or "air" -- this can be used to clear buildable_to nodes even though we are using a multinode mesh
|
||||
minetest.set_node(pos2, { name = node2, param2 = (node2 ~= "air" and fdir) or nil })
|
||||
-- do not assume by default, as we still might want to allow overlapping in some cases
|
||||
local has_facedir = node2 ~= "air"
|
||||
if node2 == "placeholder" then
|
||||
has_facedir = false
|
||||
node2 = placeholder_node
|
||||
end
|
||||
minetest.set_node(pos2, { name = node2, param2 = (has_facedir and fdir) or nil })
|
||||
|
||||
-- call after_place_node of the placed node if available
|
||||
local ctrl_node_def = minetest.registered_nodes[node1]
|
||||
|
@ -1,5 +1,6 @@
|
||||
homedecor = homedecor or {}
|
||||
local S = homedecor.gettext
|
||||
local placeholder_node = "homedecor:expansion_placeholder"
|
||||
|
||||
--wrapper around minetest.register_node that sets sane defaults and interprets some specialized settings
|
||||
function homedecor.register(name, original_def)
|
||||
@ -59,7 +60,8 @@ function homedecor.register(name, original_def)
|
||||
def.after_dig_node = def.after_dig_node or function(pos, oldnode, oldmetadata, digger)
|
||||
if expand.top and expand.forward ~= "air" then
|
||||
local top_pos = { x=pos.x, y=pos.y+1, z=pos.z }
|
||||
if minetest.get_node(top_pos).name == expand.top then
|
||||
local node = minetest.get_node(top_pos).name
|
||||
if node == expand.top or node == placeholder_node then
|
||||
minetest.remove_node(top_pos)
|
||||
end
|
||||
end
|
||||
@ -69,13 +71,15 @@ function homedecor.register(name, original_def)
|
||||
|
||||
if expand.right and expand.forward ~= "air" then
|
||||
local right_pos = { x=pos.x+homedecor.fdir_to_right[fdir+1][1], y=pos.y, z=pos.z+homedecor.fdir_to_right[fdir+1][2] }
|
||||
if minetest.get_node(right_pos).name == expand.right then
|
||||
local node = minetest.get_node(right_pos).name
|
||||
if node == expand.right or node == placeholder_node then
|
||||
minetest.remove_node(right_pos)
|
||||
end
|
||||
end
|
||||
if expand.forward and expand.forward ~= "air" then
|
||||
local forward_pos = { x=pos.x+homedecor.fdir_to_fwd[fdir+1][1], y=pos.y, z=pos.z+homedecor.fdir_to_fwd[fdir+1][2] }
|
||||
if minetest.get_node(forward_pos).name == expand.forward then
|
||||
local node = minetest.get_node(forward_pos).name
|
||||
if node == expand.forward or node == placeholder_node then
|
||||
minetest.remove_node(forward_pos)
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user