make hunters avoid repaired ancient lanterns

This commit is contained in:
FaceDeer 2022-08-07 14:43:08 -06:00
parent bc07e123ce
commit cdaeb36b14
2 changed files with 25 additions and 18 deletions

View File

@ -13,6 +13,9 @@ if minetest.get_modpath("hunter_statue") and df_underworld_items.config.underwor
tnt_vulnerable = true, tnt_vulnerable = true,
tnt_debris = "df_underworld_items:slade_sand", tnt_debris = "df_underworld_items:slade_sand",
groups = {hunter_statue = 1, falling_node = 1, immortal = 1}, groups = {hunter_statue = 1, falling_node = 1, immortal = 1},
hunters_allowed_here = function(pos)
return not minetest.find_node_near(pos, 6, "df_underworld_items:ancient_lantern_slade", true)
end,
other_overrides = { other_overrides = {
can_dig = function(pos, player) can_dig = function(pos, player)
if player then if player then

View File

@ -37,6 +37,7 @@ local test_array = {
-- knockback = 16 -- knockback = 16
-- tnt_vulnerable = false -- tnt_vulnerable = false
-- tnt_debris = -- tnt_debris =
-- hunters_allowed_here = -- function(pos)
-- other_overrides = -- other_overrides =
--} --}
@ -74,6 +75,7 @@ hunter_statue.register_hunter_statue = function(node_name, statue_def)
local knockback = statue_def.knockback or 16 local knockback = statue_def.knockback or 16
local damage = statue_def.damage or 8 local damage = statue_def.damage or 8
local hunters_allowed_here = statue_def.hunters_allowed_here
minetest.register_node(node_name, def) minetest.register_node(node_name, def)
@ -124,6 +126,7 @@ hunter_statue.register_hunter_statue = function(node_name, statue_def)
local new_pos = vector.round(vector.add(pos, player_dir)) local new_pos = vector.round(vector.add(pos, player_dir))
for _, add_pos in ipairs(test_array) do for _, add_pos in ipairs(test_array) do
local test_base = vector.add(new_pos, add_pos) local test_base = vector.add(new_pos, add_pos)
if hunters_allowed_here == nil or hunters_allowed_here(test_base) then
local test_base_node = minetest.get_node(test_base) local test_base_node = minetest.get_node(test_base)
local test_base_node_def = minetest.registered_nodes[test_base_node.name] local test_base_node_def = minetest.registered_nodes[test_base_node.name]
if test_base_node_def and test_base_node_def.buildable_to then if test_base_node_def and test_base_node_def.buildable_to then
@ -146,6 +149,7 @@ hunter_statue.register_hunter_statue = function(node_name, statue_def)
end end
end end
end end
end
if node.param2 ~= new_facedir then if node.param2 ~= new_facedir then
node.param2 = new_facedir node.param2 = new_facedir
minetest.set_node(pos, node) minetest.set_node(pos, node)