mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-12-04 16:53:46 +01:00
Document vl_projectile.replace_with_item_drop
This commit is contained in:
parent
4240f9664c
commit
f5e251b9f6
@ -57,6 +57,18 @@ Arguments:
|
|||||||
* `owner`: passed thru unmodified
|
* `owner`: passed thru unmodified
|
||||||
* `extra`: 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
|
## Custom Projectile Behaviors
|
||||||
|
|
||||||
The projectile API supports specifying the behaviors that a projectile will exhibit. There are several
|
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
|
end
|
||||||
|
|
||||||
function mod.replace_with_item_drop(self, pos, entity_def, projectile_def)
|
function mod.replace_with_item_drop(self, pos, projectile_def)
|
||||||
local item = self._arrow_item or projectile_def.item
|
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
|
if self._collectable and not minetest.is_creative_enabled("") then
|
||||||
local item = minetest.add_item(pos, item)
|
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 = minetest.get_node(self._stuckin)
|
||||||
local node_def = minetest.registered_nodes[node.name]
|
local node_def = minetest.registered_nodes[node.name]
|
||||||
if node_def and node_def.walkable == false then
|
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
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user