Move arrow-node logic out of mcl_bows/arrow.lua and into the node definitions under _vl_projectile.on_collide
This commit is contained in:
parent
ce01519faf
commit
0b5cf3af99
|
@ -27,6 +27,11 @@ minetest.register_node("mcl_target:target_off", {
|
|||
rules = mesecon.rules.alldirs,
|
||||
},
|
||||
},
|
||||
_vl_projectile = {
|
||||
on_collide = function(projectile, pos, node, node_def)
|
||||
mcl_target.hit(pos, 1) --10 redstone ticks
|
||||
end
|
||||
},
|
||||
_mcl_blast_resistance = 0.5,
|
||||
_mcl_hardness = 0.5,
|
||||
})
|
||||
|
@ -67,4 +72,4 @@ if mod_farming then
|
|||
{"", "mesecons:redstone", ""},
|
||||
},
|
||||
})
|
||||
end
|
||||
end
|
||||
|
|
|
@ -151,6 +151,20 @@ function mesecon.register_button(basename, description, texture, recipeitem, sou
|
|||
}},
|
||||
_mcl_button_basename = basename,
|
||||
_mcl_button_timer = button_timer,
|
||||
_vl_projectile = {
|
||||
on_collide = function(projectile, pos, node, node_def)
|
||||
pos = vector.round(pos)
|
||||
|
||||
-- Push the button! Push, push, push the button!
|
||||
if node_def.groups.button_push_by_arrow == 1 then
|
||||
minetest.log("hit"..dump({
|
||||
pos = pos,
|
||||
node = node,
|
||||
}))
|
||||
mesecon.push_button(pos, node)
|
||||
end
|
||||
end
|
||||
},
|
||||
|
||||
_mcl_blast_resistance = 0.5,
|
||||
_mcl_hardness = 0.5,
|
||||
|
|
|
@ -198,28 +198,11 @@ local arrow_entity = {
|
|||
|
||||
minetest.sound_play({name="mcl_bows_hit_other", gain=0.3}, {pos=self.object:get_pos(), max_hear_distance=16}, true)
|
||||
|
||||
if mcl_burning.is_burning(self.object) and snode.name == "mcl_tnt:tnt" then
|
||||
tnt.ignite(self._stuckin)
|
||||
end
|
||||
|
||||
-- Ignite Campfires
|
||||
if mod_campfire and mcl_burning.is_burning(self.object) and minetest.get_item_group(snode.name, "campfire") ~= 0 then
|
||||
mcl_campfires.light_campfire(self._stuckin)
|
||||
end
|
||||
|
||||
-- Activate target
|
||||
if mod_target and snode.name == "mcl_target:target_off" then
|
||||
mcl_target.hit(self._stuckin, 1) --10 redstone ticks
|
||||
end
|
||||
|
||||
-- Push the button! Push, push, push the button!
|
||||
if mod_button and minetest.get_item_group(node.name, "button") > 0 and minetest.get_item_group(node.name, "button_push_by_arrow") == 1 then
|
||||
local bdir = minetest.wallmounted_to_dir(node.param2)
|
||||
-- Check the button orientation
|
||||
if vector.equals(vector.add(dpos, bdir), self._stuckin) then
|
||||
mesecon.push_button(dpos, node)
|
||||
end
|
||||
end
|
||||
-- Temporary handler here to test moving this to node definitions.
|
||||
-- TODO: move to vl_projectile when the stuck logic gets moved there and before merging
|
||||
-- Trigger hits on the node the projectile hit
|
||||
local hook = sdef._vl_projectile and sdef._vl_projectile.on_collide
|
||||
if hook then hook(self, self._stuckin, snode, sdef) end
|
||||
end,
|
||||
on_collide_with_entity = function(self, pos, obj)
|
||||
local is_player = obj:is_player()
|
||||
|
|
|
@ -261,6 +261,14 @@ function mcl_campfires.register_campfire(name, def)
|
|||
},
|
||||
_mcl_blast_resistance = 2,
|
||||
_mcl_hardness = 2,
|
||||
_vl_projectile = {
|
||||
on_collide = function(projectile, pos, node, node_def)
|
||||
-- Ignite Campfires
|
||||
if mcl_burning.is_burning(projectile) then
|
||||
mcl_campfires.light_campfire(pos)
|
||||
end
|
||||
end
|
||||
},
|
||||
after_dig_node = function(pos, node, oldmeta, digger)
|
||||
campfire_drops(pos, digger, def.drops, name.."_lit")
|
||||
end,
|
||||
|
|
|
@ -110,6 +110,13 @@ minetest.register_node("mcl_tnt:tnt", {
|
|||
tnt.ignite(droppos)
|
||||
end
|
||||
end,
|
||||
_vl_projectile = {
|
||||
on_collide = function(projectile, pos, node, node_def)
|
||||
if mcl_burning.is_burning(projectile) then
|
||||
tnt.ignite(pos)
|
||||
end
|
||||
end
|
||||
},
|
||||
sounds = sounds,
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue