Document vl_projectile.replace_with_item_drop
This commit is contained in:
parent
75370fbac9
commit
05c043dcf3
|
@ -57,6 +57,18 @@ Arguments:
|
|||
* `owner`: passed thru unmodified
|
||||
* `extra`: passed thru unmodified
|
||||
|
||||
## `vl_projectile.replace_with_item_drop(projectile_lua_entity, pos, projectile_def)`
|
||||
|
||||
Removes the projectile and replaces it with an item entity based on either the entity's `_arrow_item` field or
|
||||
the value `self._vl_projectile.item`.
|
||||
|
||||
Arguments:
|
||||
|
||||
* `projectile_lua_entity`: the lua entity of the projectile to be replaced.
|
||||
* `pos`: the position to create the item entity
|
||||
* `projectile_def`: The projectile's `_vl_projectile` field. If not provided, it will be
|
||||
extracted from the projectile's lua entity.
|
||||
|
||||
## Custom Projectile Behaviors
|
||||
|
||||
The projectile API supports specifying the behaviors that a projectile will exhibit. There are several
|
||||
|
|
|
@ -233,8 +233,15 @@ function mod.has_tracer(self, dtime, entity_def, projectile_def)
|
|||
})
|
||||
end
|
||||
|
||||
function mod.replace_with_item_drop(self, pos, entity_def, projectile_def)
|
||||
local item = self._arrow_item or projectile_def.item
|
||||
function mod.replace_with_item_drop(self, pos, projectile_def)
|
||||
local item = self._arrow_item
|
||||
|
||||
if not item then
|
||||
projectile_def = projectile_def or self._vl_projectile
|
||||
if not projectile_def then return end
|
||||
|
||||
item = projectile_def.item
|
||||
end
|
||||
|
||||
if self._collectable and not minetest.is_creative_enabled("") then
|
||||
local item = minetest.add_item(pos, item)
|
||||
|
@ -269,7 +276,7 @@ local function stuck_on_step(self, dtime, entity_def, projectile_def)
|
|||
local node = minetest.get_node(self._stuckin)
|
||||
local node_def = minetest.registered_nodes[node.name]
|
||||
if node_def and node_def.walkable == false then
|
||||
mod.replace_with_item_drop(self, pos, entity_def, projectile_def)
|
||||
mod.replace_with_item_drop(self, pos, projectile_def)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue