Skip to content

Commit 20793b8

Browse files
committed
remove explode_center
1 parent 960aff2 commit 20793b8

File tree

2 files changed

+12
-25
lines changed

2 files changed

+12
-25
lines changed

game_api.txt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,11 @@ Doors API
167167

168168
The doors mod allows modders to register custom doors and trapdoors.
169169

170-
`doors.registered_doors[name] = Door definition`
171-
* Table of registered doors, indexed by door name
170+
`doors.registered_doors[name] = Door definition`
171+
* Table of registered doors, indexed by door name
172172

173-
`doors.registered_trapdoors[name] = Trapdoor definition`
174-
* Table of registered trap doors, indexed by trap door name
173+
`doors.registered_trapdoors[name] = Trapdoor definition`
174+
* Table of registered trap doors, indexed by trap door name
175175

176176
`doors.register_door(name, def)`
177177

@@ -214,7 +214,7 @@ The doors mod allows modders to register custom doors and trapdoors.
214214
* `pos` Position of the door
215215
* `node` Node definition
216216
* `clicker` Player definition for the player that clicked on the door
217-
217+
218218
### Door definition
219219

220220
description = "Door description",
@@ -257,7 +257,7 @@ The doors mod allows modders to register custom doors and trapdoors.
257257
gain_open = 0.3, -- optional, defaults to 0.3
258258
gain_close = 0.3, -- optional, defaults to 0.3
259259
protected = false, -- If true, only placer can open the door (locked for others)
260-
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) ,
260+
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing),
261261
-- function containing the on_rightclick callback
262262
use_texture_alpha = "clip",
263263

@@ -543,8 +543,7 @@ TNT API
543543
^ Create an explosion.
544544

545545
* `position` The center of explosion.
546-
* `definition` The TNT definion as passed to `tnt.register` with the following addition:
547-
* `explode_center` false by default which removes TNT node on blast, when true will explode center node.
546+
* `definition` The TNT definion as passed to `tnt.register`.
548547

549548
`tnt.burn(position, [nodename])`
550549

mods/tnt/init.lua

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,7 @@ end
9191

9292
local basic_flame_on_construct -- cached value
9393
local function destroy(drops, npos, cid, c_air, c_fire,
94-
on_blast_queue, on_construct_queue,
95-
ignore_protection, ignore_on_blast, owner)
96-
if not ignore_protection and minetest.is_protected(npos, owner) then
97-
return cid
98-
end
99-
94+
on_blast_queue, on_construct_queue, ignore_on_blast)
10095
local def = cid_data[cid]
10196

10297
if not def then
@@ -284,7 +279,7 @@ function tnt.burn(pos, nodename)
284279
end
285280
end
286281

287-
local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owner, explode_center)
282+
local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owner)
288283
pos = vector.round(pos)
289284
-- scan for adjacent TNT nodes first, and enlarge the explosion
290285
local vm1 = VoxelManip()
@@ -293,7 +288,7 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owne
293288
local minp, maxp = vm1:read_from_map(p1, p2)
294289
local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
295290
local data = vm1:get_data()
296-
local count = 0
291+
local count = 1
297292
local c_tnt
298293
local c_tnt_burning = minetest.get_content_id("tnt:tnt_burning")
299294
local c_tnt_boom = minetest.get_content_id("tnt:boom")
@@ -304,10 +299,6 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owne
304299
else
305300
c_tnt = c_tnt_burning -- tnt is not registered if disabled
306301
end
307-
-- make sure we still have explosion even when centre node isnt tnt related
308-
if explode_center then
309-
count = 1
310-
end
311302

312303
for z = pos.z - 2, pos.z + 2 do
313304
for y = pos.y - 2, pos.y + 2 do
@@ -352,7 +343,7 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owne
352343
if (radius * radius) / (r * r) >= (pr:next(80, 125) / 100) then
353344
local cid = data[vi]
354345
local p = {x = pos.x + x, y = pos.y + y, z = pos.z + z}
355-
if cid ~= c_air and cid ~= c_ignore then
346+
if cid ~= c_air and cid ~= c_ignore and (ignore_protection or not minetest.is_protected(p, owner)) then
356347
data[vi] = destroy(drops, p, cid, c_air, c_fire,
357348
on_blast_queue, on_construct_queue,
358349
ignore_protection, ignore_on_blast, owner)
@@ -409,14 +400,11 @@ function tnt.boom(pos, def)
409400
def.damage_radius = def.damage_radius or def.radius * 2
410401
local meta = minetest.get_meta(pos)
411402
local owner = meta:get_string("owner")
412-
if not def.explode_center and def.ignore_protection ~= true then
413-
minetest.set_node(pos, {name = "tnt:boom"})
414-
end
415403
local sound = def.sound or "tnt_explode"
416404
minetest.sound_play(sound, {pos = pos, gain = 2.5,
417405
max_hear_distance = math.min(def.radius * 20, 128)}, true)
418406
local drops, radius = tnt_explode(pos, def.radius, def.ignore_protection,
419-
def.ignore_on_blast, owner, def.explode_center)
407+
def.ignore_on_blast, owner)
420408
-- append entity drops
421409
local damage_radius = (radius / math.max(1, def.radius)) * def.damage_radius
422410
entity_physics(pos, damage_radius, drops)

0 commit comments

Comments
 (0)