diff --git a/mods/snow/src/snowball.lua b/mods/snow/src/snowball.lua index f46d99d3..74014771 100755 --- a/mods/snow/src/snowball.lua +++ b/mods/snow/src/snowball.lua @@ -80,6 +80,7 @@ local snow_snowball_ENTITY = { physical = false, timer = 0, collisionbox = {-5/16,-5/16,-5/16, 5/16,5/16,5/16}, + thrower = "", } function snow_snowball_ENTITY.on_activate(self) @@ -114,18 +115,21 @@ function snow_snowball_ENTITY.on_step(self, dtime) if self.timer > 600 then -- 10 minutes are too long for a snowball to fly somewhere self.object:remove() + return end if self.timer > 0.15 then for i, v in pairs(minetest.get_objects_inside_radius(self.object:getpos(), 1)) do if v ~= self.object then local entity_name = v:get_entity_name() - if v:get_entity_name() ~= "__builtin:item" - and entity_name ~= "snow:snowball_entity" + if entity_name and entity_name ~= "snow:snowball_entity" + and entity_name ~= "__builtin:item" and entity_name ~= "gauges:hp_bar" then - if self.thrower then - v:punch(minetest.get_player_by_name(self.thrower), 1.0,{full_punch_interval=1.0, damage_groups = {fleshy=1}}) + local puncher = self.object + if self.thrower and self.thrower ~= "" and minetest.get_player_by_name(self.thrower) then + puncher = minetest.get_player_by_name(self.thrower) end + v:punch(puncher, 1.0, {full_punch_interval=1.0, damage_groups = {fleshy=1} }) minetest.add_item(self.object:getpos(), "default:snow") self.object:remove() return