From 97d966f55c8e28f4929c0355d3904cf16952fb13 Mon Sep 17 00:00:00 2001 From: upsilon Date: Sun, 9 Jul 2017 10:59:39 +0200 Subject: [PATCH] Fix a sneak bug when using more than one sling at a time --- init.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index a50a140..0e6f867 100644 --- a/init.lua +++ b/init.lua @@ -17,7 +17,7 @@ throwing.register_bow("sling:sling", { end end, spawn_arrow_entity = function(pos, arrow, player) - local obj = minetest.add_entity(pos, "sling:sling_entity") + local obj = minetest.add_entity(pos, "sling:sling_entity", tostring(sling_sneak)) obj:set_properties{ textures = {arrow}, } @@ -32,8 +32,11 @@ minetest.register_entity("sling:sling_entity", throwing.make_arrow_def{ target = throwing.target_node, on_hit_sound = "", on_throw_sound = "", + on_activate = function(self, staticdata) + self.sneak = staticdata == "true" + end, on_hit = function(self, pos, last_pos, node, object, hitter, data) - if sling_sneak == true then + if self.sneak then data.itemstack:set_count(1) end minetest.spawn_item(