Skip to content

Commit f661e8d

Browse files
committed
remove explode_center
1 parent 78de12d commit f661e8d

File tree

2 files changed

+15
-28
lines changed

2 files changed

+15
-28
lines changed

game_api.txt

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,11 @@ Doors API
165165

166166
The doors mod allows modders to register custom doors and trapdoors.
167167

168-
`doors.registered_doors[name] = Door definition`
169-
* Table of registered doors, indexed by door name
168+
`doors.registered_doors[name] = Door definition`
169+
* Table of registered doors, indexed by door name
170170

171-
`doors.registered_trapdoors[name] = Trapdoor definition`
172-
* Table of registered trap doors, indexed by trap door name
171+
`doors.registered_trapdoors[name] = Trapdoor definition`
172+
* Table of registered trap doors, indexed by trap door name
173173

174174
`doors.register_door(name, def)`
175175

@@ -212,7 +212,7 @@ The doors mod allows modders to register custom doors and trapdoors.
212212
* `pos` Position of the door
213213
* `node` Node definition
214214
* `clicker` Player definition for the player that clicked on the door
215-
215+
216216
### Door definition
217217

218218
description = "Door description",
@@ -228,7 +228,7 @@ The doors mod allows modders to register custom doors and trapdoors.
228228
gain_open = 0.3, -- optional, defaults to 0.3
229229
gain_close = 0.3, -- optional, defaults to 0.3
230230
protected = false, -- If true, only placer can open the door (locked for others)
231-
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
231+
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
232232
-- optional function containing the on_rightclick callback, defaults to a doors.door_toggle-wrapper
233233

234234
### Trapdoor definition
@@ -249,9 +249,9 @@ The doors mod allows modders to register custom doors and trapdoors.
249249
gain_open = 0.3, -- optional, defaults to 0.3
250250
gain_close = 0.3, -- optional, defaults to 0.3
251251
protected = false, -- If true, only placer can open the door (locked for others)
252-
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
252+
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
253253
-- function containing the on_rightclick callback
254-
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
254+
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
255255
-- function containing the on_rightclick callback
256256

257257
### Fence gate definition
@@ -262,7 +262,7 @@ The doors mod allows modders to register custom doors and trapdoors.
262262
material = "default:wood",
263263
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
264264
sounds = default.node_sound_wood_defaults(), -- optional
265-
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
265+
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
266266
-- function containing the on_rightclick callback
267267

268268

@@ -518,8 +518,7 @@ TNT API
518518
^ Create an explosion.
519519

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

524523
`tnt.burn(position, [nodename])`
525524

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")
@@ -303,10 +298,6 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owne
303298
else
304299
c_tnt = c_tnt_burning -- tnt is not registered if disabled
305300
end
306-
-- make sure we still have explosion even when centre node isnt tnt related
307-
if explode_center then
308-
count = 1
309-
end
310301

311302
for z = pos.z - 2, pos.z + 2 do
312303
for y = pos.y - 2, pos.y + 2 do
@@ -351,7 +342,7 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owne
351342
if (radius * radius) / (r * r) >= (pr:next(80, 125) / 100) then
352343
local cid = data[vi]
353344
local p = {x = pos.x + x, y = pos.y + y, z = pos.z + z}
354-
if cid ~= c_air then
345+
if cid ~= c_air and (ignore_protection or not minetest.is_protected(p, owner)) then
355346
data[vi] = destroy(drops, p, cid, c_air, c_fire,
356347
on_blast_queue, on_construct_queue,
357348
ignore_protection, ignore_on_blast, owner)
@@ -408,14 +399,11 @@ function tnt.boom(pos, def)
408399
def.damage_radius = def.damage_radius or def.radius * 2
409400
local meta = minetest.get_meta(pos)
410401
local owner = meta:get_string("owner")
411-
if not def.explode_center and def.ignore_protection ~= true then
412-
minetest.set_node(pos, {name = "tnt:boom"})
413-
end
414402
local sound = def.sound or "tnt_explode"
415403
minetest.sound_play(sound, {pos = pos, gain = 2.5,
416404
max_hear_distance = math.min(def.radius * 20, 128)}, true)
417405
local drops, radius = tnt_explode(pos, def.radius, def.ignore_protection,
418-
def.ignore_on_blast, owner, def.explode_center)
406+
def.ignore_on_blast, owner)
419407
-- append entity drops
420408
local damage_radius = (radius / math.max(1, def.radius)) * def.damage_radius
421409
entity_physics(pos, damage_radius, drops)

0 commit comments

Comments
 (0)