Add hidden mast segments

master
Wuzzy 2022-07-02 17:22:18 +02:00
parent 71853506ef
commit 7dc6217492
3 changed files with 59 additions and 1 deletions

View File

@ -248,7 +248,7 @@ minetest.register_node( "pride_flags:upper_mast", {
},
collision_box = {
type = "fixed",
fixed = { { -3/32, -1/2, -3/32, 3/32, 27/16, 3/32 } },
fixed = { { -3/32, -1/2, -3/32, 3/32, 1/5, 3/32 } },
},
on_rightclick = function ( pos, node, player )
@ -261,6 +261,12 @@ minetest.register_node( "pride_flags:upper_mast", {
on_construct = function ( pos )
spawn_flag ( pos )
local above1 = {x=pos.x, y=pos.y+1, z=pos.z}
local above2 = {x=pos.x, y=pos.y+2, z=pos.z}
local param2 = minetest.get_node( pos ).param2
minetest.set_node( above1, { name = "pride_flags:upper_mast_hidden_1" } )
minetest.set_node( above2, { name = "pride_flags:upper_mast_hidden_2" } )
end,
on_destruct = function ( pos )
@ -270,6 +276,17 @@ minetest.register_node( "pride_flags:upper_mast", {
end
end,
after_destruct = function( pos )
local above1 = {x=pos.x, y=pos.y+1, z=pos.z}
local above2 = {x=pos.x, y=pos.y+2, z=pos.z}
if minetest.get_node( above1 ).name == "pride_flags:upper_mast_hidden_1" then
minetest.remove_node( above1 )
end
if minetest.get_node( above2 ).name == "pride_flags:upper_mast_hidden_2" then
minetest.remove_node( above2 )
end
end,
on_rotate = function(pos, node, user, mode, new_param2)
if mode == screwdriver.ROTATE_AXIS then
return false
@ -281,3 +298,44 @@ minetest.register_node( "pride_flags:upper_mast", {
end
end,
} )
-- Add 2 hidden upper mast segments to block all the nodes
-- the upper mast occupies. This is also needed to prevent
-- collision issues with overhigh nodes.
-- These nodes will be automatically
-- added/removed when the upper mast is constructed
-- or destructed.
minetest.register_node( "pride_flags:upper_mast_hidden_1", {
drawtype = "airlike",
pointable = false,
paramtype = "light",
sunlight_propagates = true,
wield_image = "pride_flags_pole_hidden1_inv.png",
inventory_image = "pride_flags_pole_hidden1_inv.png",
groups = { not_in_creative_inventory = 1 },
sounds = metal_sounds,
collision_box = {
type = "fixed",
fixed = { { -3/32, -1/2, -3/32, 3/32, 1/5, 3/32 } },
},
on_blast = function()
return
end,
})
minetest.register_node( "pride_flags:upper_mast_hidden_2", {
drawtype = "airlike",
pointable = false,
paramtype = "light",
sunlight_propagates = true,
wield_image = "pride_flags_pole_hidden2_inv.png",
inventory_image = "pride_flags_pole_hidden2_inv.png",
groups = { not_in_creative_inventory = 1 },
sounds = metal_sounds,
collision_box = {
type = "fixed",
fixed = { { -3/32, -1/2, -3/32, 3/32, -5/16, 3/32 } },
},
on_blast = function()
return
end,
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB