3 Remove only arrow entities
This commit is contained in:
commit
53b9b56b26
|
@ -1,3 +1,6 @@
|
|||
unused_args = false
|
||||
allow_defined_top = true
|
||||
|
||||
globals = {
|
||||
'x_bows'
|
||||
}
|
||||
|
@ -12,5 +15,6 @@ read_globals = {
|
|||
'playerphysics',
|
||||
'hb',
|
||||
'mesecon',
|
||||
'dump',
|
||||
'player_monoids'
|
||||
}
|
||||
|
|
12
arrow.lua
12
arrow.lua
|
@ -145,7 +145,7 @@ minetest.register_entity('x_bows:arrow_entity', {
|
|||
})
|
||||
end,
|
||||
|
||||
on_death = function(self, killer) --luacheck:ignore
|
||||
on_death = function(self, killer)
|
||||
if not self._old_pos then
|
||||
self.object:remove()
|
||||
return
|
||||
|
@ -457,9 +457,15 @@ minetest.register_entity('x_bows:arrow_entity', {
|
|||
self._attached_to.type = pointed_thing.type
|
||||
self._attached_to.pos = position
|
||||
|
||||
local children = pointed_thing.ref:get_children()
|
||||
|
||||
-- remove last arrow when too many already attached
|
||||
local children = {}
|
||||
|
||||
for _, object in ipairs(pointed_thing.ref:get_children()) do
|
||||
if object:get_luaentity() and object:get_luaentity().name == 'x_bows:arrow_entity' then
|
||||
table.insert(children, object)
|
||||
end
|
||||
end
|
||||
|
||||
if #children >= 5 then
|
||||
children[1]:remove()
|
||||
end
|
||||
|
|
2
init.lua
2
init.lua
|
@ -160,7 +160,7 @@ function x_bows.load(itemstack, user, pointed_thing)
|
|||
end
|
||||
end
|
||||
|
||||
function x_bows.shoot(itemstack, user, pointed_thing) --luacheck:ignore
|
||||
function x_bows.shoot(itemstack, user, pointed_thing)
|
||||
local time_shoot = minetest.get_us_time();
|
||||
local meta = itemstack:get_meta()
|
||||
local meta_arrow = meta:get_string('arrow')
|
||||
|
|
|
@ -32,7 +32,7 @@ minetest.register_node('x_bows:target', {
|
|||
groups = {snappy=3, flammable=4, fall_damage_add_percent=-30},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
mesecons = {receptor = {state = 'off'}},
|
||||
on_timer = function (pos, elapsed) --luacheck:ignore
|
||||
on_timer = function (pos, elapsed)
|
||||
mesecon.receptor_off(pos)
|
||||
return false
|
||||
end,
|
||||
|
|
Ŝarĝante…
Reference in New Issue