From ec890d4a56abdaeb57372818318d1a892bec35df Mon Sep 17 00:00:00 2001 From: TenPlus1 Date: Wed, 23 Sep 2015 16:09:42 +0100 Subject: [PATCH] Tweaked arrow code --- api.lua | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/api.lua b/api.lua index f571fbc..1a6d623 100644 --- a/api.lua +++ b/api.lua @@ -1,4 +1,4 @@ --- Mobs Api (17th September 2015) +-- Mobs Api (23rd September 2015) mobs = {} mobs.mod = "redo" @@ -1479,25 +1479,26 @@ function mobs:register_arrow(name, def) return end - local engage = 10 - (self.velocity / 2) -- clear entity before arrow becomes active - local node = minetest.get_node_or_nil(pos) - if node then node = node.name else node = "air" end + if self.hit_node then + local node = minetest.get_node_or_nil(pos) + if node then node = node.name else node = "air" end - if self.hit_node - and minetest.registered_nodes[node] - and minetest.registered_nodes[node].walkable then - self.hit_node(self, pos, node) - if self.drop == true then - pos.y = pos.y + 1 - self.lastpos = (self.lastpos or pos) - minetest.add_item(self.lastpos, self.object:get_luaentity().name) + if minetest.registered_nodes[node] + and minetest.registered_nodes[node].walkable then + self.hit_node(self, pos, node) + if self.drop == true then + pos.y = pos.y + 1 + self.lastpos = (self.lastpos or pos) + minetest.add_item(self.lastpos, self.object:get_luaentity().name) + end + self.object:remove() ; -- print ("hit node") + return end - self.object:remove() ; -- print ("hit node") - return end if (self.hit_player or self.hit_mob) - and self.timer > engage then + -- clear entity before arrow becomes active + and self.timer > (10 - (self.velocity / 2)) then for _,player in pairs(minetest.get_objects_inside_radius(pos, 1.0)) do if self.hit_player and player:is_player() then