mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-16 16:11:06 +01:00
Add hook to allow piercing enchantment to be implemented
This commit is contained in:
parent
d6f59132d0
commit
06bd99ac33
2 changed files with 14 additions and 3 deletions
|
@ -17,7 +17,10 @@ Arguments:
|
|||
* `damages_players`: if true, the projectile will deal damage to players.
|
||||
* `damage_groups`: damage group information to use for `punch()`. May be a function of type `function(projectile, entity_def, projectile_def, obj)`
|
||||
that returns dynamic damange group information.
|
||||
* `allow_punching`: will the projectile punch entities it collides with. May be a function of type `function(projectile, entity_def, projectile_def, obj)`.
|
||||
* `allow_punching`: will the projectile punch entities it collides with. May be either a boolean or a function of type `function(projectile, entity_def, projectile_def, obj)`.
|
||||
* `survive_collision`: will the projectile surive collisions. May be either a boolean or a fnction of type `function(projectile, entity_def, projectile_def, type, ...)`.
|
||||
* If `type` is "node" then the additional parameters `node, node_def` will be provided.
|
||||
* If `type` is "entity" then the additional parameter `objet` will be provided.
|
||||
* `behaviors`: a list of behavior callbacks that define the projectile's behavior. This mod provides the following
|
||||
behaviors: `vl_projectiles.collides_with_solids`, `vl_projectiles.collides_with_entities` and `vl_projectiles.raycast_collides_with_entities`
|
||||
* `sounds`: sounds for this projectile. All fields take a table with three parameters corresponding to the
|
||||
|
|
|
@ -240,7 +240,11 @@ function mod.collides_with_solids(self, dtime, entity_def, projectile_def)
|
|||
end
|
||||
|
||||
-- Normally objects should be removed on collision with solids
|
||||
if not projectile_def.survive_collision then
|
||||
local survive_collision = projectile_def.survive_collision
|
||||
if type(survive_collision) == "function" then
|
||||
survive_collision = survive_collision(self, entity_def, projectile_def, "node", node, node_def)
|
||||
end
|
||||
if not survive_collision then
|
||||
self._removed = true
|
||||
self.object:remove()
|
||||
end
|
||||
|
@ -326,7 +330,11 @@ local function handle_entity_collision(self, entity_def, projectile_def, object)
|
|||
end
|
||||
|
||||
-- Normally objects should be removed on collision with entities
|
||||
if not projectile_def.survive_collision then
|
||||
local survive_collision = projectile_def.survive_collision
|
||||
if type(survive_collision) == "function" then
|
||||
survive_collision = survive_collision(self, entity_def, projectile_def, "entity", object)
|
||||
end
|
||||
if not survive_collision then
|
||||
self._removed = true
|
||||
self.object:remove()
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue