diff --git a/.luacheckrc b/.luacheckrc index 076aa9e..40ff5d3 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -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' } diff --git a/arrow.lua b/arrow.lua index a69d2b9..a4d081c 100644 --- a/arrow.lua +++ b/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 @@ -520,7 +526,7 @@ minetest.register_entity('x_bows:arrow_entity', { for _, object in ipairs(minetest.get_objects_inside_radius(pointed_thing.under, 1)) do if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == 'x_bows:arrow_entity' then - table.insert(children ,object) + table.insert(children, object) end end diff --git a/init.lua b/init.lua index c014443..5e90c1e 100644 --- a/init.lua +++ b/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') diff --git a/nodes.lua b/nodes.lua index 6dfe303..9c8200c 100644 --- a/nodes.lua +++ b/nodes.lua @@ -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,