@@ -99,7 +99,7 @@ local function destroy(drops, npos, cid, c_air, c_fire, on_blast_queue, ignore_p
9999 return c_fire
100100 else
101101 local node_drops = minetest .get_node_drops (def .name , " " )
102- for _ , item in ipairs (node_drops ) do
102+ for _ , item in pairs (node_drops ) do
103103 add_drop (drops , item )
104104 end
105105 return c_air
@@ -181,7 +181,7 @@ local function entity_physics(pos, radius, drops)
181181 }, nil )
182182 end
183183 end
184- for _ , item in ipairs (entity_drops ) do
184+ for _ , item in pairs (entity_drops ) do
185185 add_drop (drops , item )
186186 end
187187 end
@@ -248,8 +248,8 @@ local function add_effects(pos, radius, drops)
248248 })
249249end
250250
251- function tnt .burn (pos )
252- local name = minetest .get_node (pos ).name
251+ function tnt .burn (pos , nodename )
252+ local name = nodename or minetest .get_node (pos ).name
253253 local group = minetest .get_item_group (name , " tnt" )
254254 if group > 0 then
255255 minetest .sound_play (" tnt_ignite" , {pos = pos })
@@ -333,24 +333,25 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast)
333333 vm :update_liquids ()
334334
335335 -- call nodeupdate for everything within 1.5x blast radius
336+ for y = - radius * 1.5 , radius * 1.5 do
336337 for z = - radius * 1.5 , radius * 1.5 do
337338 for x = - radius * 1.5 , radius * 1.5 do
338- for y = - radius * 1.5 , radius * 1.5 do
339- local s = vector .add (pos , { x = x , y = y , z = z } )
340- local r = vector .distance ( pos , s )
339+ local rad = { x = x , y = y , z = z }
340+ local s = vector .add (pos , rad )
341+ local r = vector .length ( rad )
341342 if r / radius < 1.4 then
342- nodeupdate (s )
343+ nodeupdate_single (s )
343344 end
344345 end
345346 end
346347 end
347348
348- for _ , queued_data in ipairs (on_blast_queue ) do
349+ for _ , queued_data in pairs (on_blast_queue ) do
349350 local dist = math.max (1 , vector .distance (queued_data .pos , pos ))
350351 local intensity = (radius * radius ) / (dist * dist )
351352 local node_drops = queued_data .on_blast (queued_data .pos , intensity )
352353 if node_drops then
353- for _ , item in ipairs (node_drops ) do
354+ for _ , item in pairs (node_drops ) do
354355 add_drop (drops , item )
355356 end
356357 end
@@ -408,11 +409,11 @@ minetest.register_node("tnt:gunpowder", {
408409
409410 on_punch = function (pos , node , puncher )
410411 if puncher :get_wielded_item ():get_name () == " default:torch" then
411- tnt .burn (pos )
412+ tnt .burn (pos , node . name )
412413 end
413414 end ,
414415 on_blast = function (pos , intensity )
415- tnt .burn (pos )
416+ tnt .burn (pos , " tnt:gunpowder " )
416417 end ,
417418})
418419
@@ -511,7 +512,9 @@ if enable_tnt then
511512 neighbors = {" fire:basic_flame" , " default:lava_source" , " default:lava_flowing" },
512513 interval = 4 ,
513514 chance = 1 ,
514- action = tnt .burn ,
515+ action = function (pos , node )
516+ tnt .burn (pos , node .name )
517+ end ,
515518 })
516519end
517520
0 commit comments