diff --git a/arrow.lua b/arrow.lua index 86263c1..60ab977 100644 --- a/arrow.lua +++ b/arrow.lua @@ -10,13 +10,13 @@ bows.on_hit_object=function(self,target,hp,user,lastpos) local opos=target:getpos() local dir = user:get_look_dir() self.object:set_attach(target, "", {x=(opos.x-pos.x)*4,y=(pos.y-opos.y)*4,z=(pos.z-opos.z)*4},{x=0,y=-90,z=0}) - else + else bows.arrow_remove(self) + minetest.add_item(self.object:getpos(), self) end return self end - bows.on_hit_node=function(self,pos,user,lastpos) if not minetest.registered_nodes[minetest.get_node(pos).name].node_box then local mpos={x=(pos.x-lastpos.x),y=(pos.y-lastpos.y),z=(pos.z-lastpos.z)} @@ -48,7 +48,7 @@ bows.arrow_remove=function(self) if self.target then self.target:punch(self.object, {full_punch_interval=1,damage_groups={fleshy=4}}, "default:bronze_pick", nil) end self.object:set_hp(0) self.object:punch(self.object, {full_punch_interval=1.0,damage_groups={fleshy=4}}, "bows:bow_wood", nil) - return self + return self end minetest.register_entity("bows:arrow",{ @@ -71,8 +71,8 @@ minetest.register_entity("bows:arrow",{ self.target:setvelocity({x=0, y=4, z=0}) self.target:setacceleration({x=0, y=-10, z=0}) self.on_punch=function(self, puncher, time_from_last_punch, tool_capabilities, dir) end - bows.arrow_remove(self) - end + bows.arrow_remove(self) + end return self end, on_activate = function(self, staticdata) @@ -84,7 +84,8 @@ minetest.register_entity("bows:arrow",{ bows.tmp=nil self.object:set_properties({textures={self.arrow}}) else - self.object:remove() + minetest.add_item(self.object:getpos(), self.arrow) + self.object:remove() end end, stuck=false, @@ -98,7 +99,8 @@ minetest.register_entity("bows:arrow",{ if self.stuck then if self.target and self.target:get_hp()<=1 then self.timer=-1 end if self.timer<0 then - bows.arrow_remove(self) + minetest.add_item(self.object:getpos(), self.arrow) + bows.arrow_remove(self) end return self end @@ -132,4 +134,4 @@ minetest.register_entity("bows:arrow",{ end return self end, -}) \ No newline at end of file +})