diff --git a/changelog.txt b/changelog.txt index 8555a28..da0e1aa 100644 --- a/changelog.txt +++ b/changelog.txt @@ -51,3 +51,4 @@ v1.1.3: Fixes: -A crash that could occur from pulverizing a charging weapon. + -node_damage mod not actually being optional, and causing a crash when not included. diff --git a/init.lua b/init.lua index 2e008d4..22699a5 100644 --- a/init.lua +++ b/init.lua @@ -485,19 +485,22 @@ if tnt then --Upon impact, create a small explosion. on_impact = function(self, collisions) local pos = self.object:get_pos() - local r = 4 - tnt.boom(self.object:get_pos(), {radius = 2, damage_radius = 2}) + tnt.boom(pos, {radius = 2, damage_radius = 2}) - for a = -r, r do - for b = -r, r do - for c = -r, r do - local npos = vector.add(pos, {x=a, y=b, z=c}) - local dist = vector.distance(pos, npos) - local num = math.random(0, math.ceil(r / math.max(1, dist))) + if node_damage then + local r = 4 - if dist <= r and num > 0 then - node_damage.damage(npos, nil, nil, num) + for a = -r, r do + for b = -r, r do + for c = -r, r do + local npos = vector.add(pos, {x=a, y=b, z=c}) + local dist = vector.distance(pos, npos) + local num = math.random(0, math.ceil(r / math.max(1, dist))) + + if dist <= r and num > 0 then + node_damage.damage(npos, nil, nil, num) + end end end end