remove explode_center

This commit is contained in:
flux 2022-01-13 17:07:33 -08:00
parent 960aff2f63
commit 20793b8118
No known key found for this signature in database
GPG Key ID: 9333B27816848A15
2 changed files with 12 additions and 25 deletions

View File

@ -167,11 +167,11 @@ Doors API
The doors mod allows modders to register custom doors and trapdoors.
`doors.registered_doors[name] = Door definition`
* Table of registered doors, indexed by door name
`doors.registered_doors[name] = Door definition`
* Table of registered doors, indexed by door name
`doors.registered_trapdoors[name] = Trapdoor definition`
* Table of registered trap doors, indexed by trap door name
`doors.registered_trapdoors[name] = Trapdoor definition`
* Table of registered trap doors, indexed by trap door name
`doors.register_door(name, def)`
@ -214,7 +214,7 @@ The doors mod allows modders to register custom doors and trapdoors.
* `pos` Position of the door
* `node` Node definition
* `clicker` Player definition for the player that clicked on the door
### Door definition
description = "Door description",
@ -257,7 +257,7 @@ The doors mod allows modders to register custom doors and trapdoors.
gain_open = 0.3, -- optional, defaults to 0.3
gain_close = 0.3, -- optional, defaults to 0.3
protected = false, -- If true, only placer can open the door (locked for others)
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) ,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing),
-- function containing the on_rightclick callback
use_texture_alpha = "clip",
@ -543,8 +543,7 @@ TNT API
^ Create an explosion.
* `position` The center of explosion.
* `definition` The TNT definion as passed to `tnt.register` with the following addition:
* `explode_center` false by default which removes TNT node on blast, when true will explode center node.
* `definition` The TNT definion as passed to `tnt.register`.
`tnt.burn(position, [nodename])`

View File

@ -91,12 +91,7 @@ end
local basic_flame_on_construct -- cached value
local function destroy(drops, npos, cid, c_air, c_fire,
on_blast_queue, on_construct_queue,
ignore_protection, ignore_on_blast, owner)
if not ignore_protection and minetest.is_protected(npos, owner) then
return cid
end
on_blast_queue, on_construct_queue, ignore_on_blast)
local def = cid_data[cid]
if not def then
@ -284,7 +279,7 @@ function tnt.burn(pos, nodename)
end
end
local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owner, explode_center)
local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owner)
pos = vector.round(pos)
-- scan for adjacent TNT nodes first, and enlarge the explosion
local vm1 = VoxelManip()
@ -293,7 +288,7 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owne
local minp, maxp = vm1:read_from_map(p1, p2)
local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
local data = vm1:get_data()
local count = 0
local count = 1
local c_tnt
local c_tnt_burning = minetest.get_content_id("tnt:tnt_burning")
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
else
c_tnt = c_tnt_burning -- tnt is not registered if disabled
end
-- make sure we still have explosion even when centre node isnt tnt related
if explode_center then
count = 1
end
for z = pos.z - 2, pos.z + 2 do
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
if (radius * radius) / (r * r) >= (pr:next(80, 125) / 100) then
local cid = data[vi]
local p = {x = pos.x + x, y = pos.y + y, z = pos.z + z}
if cid ~= c_air and cid ~= c_ignore then
if cid ~= c_air and cid ~= c_ignore and (ignore_protection or not minetest.is_protected(p, owner)) then
data[vi] = destroy(drops, p, cid, c_air, c_fire,
on_blast_queue, on_construct_queue,
ignore_protection, ignore_on_blast, owner)
@ -409,14 +400,11 @@ function tnt.boom(pos, def)
def.damage_radius = def.damage_radius or def.radius * 2
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
if not def.explode_center and def.ignore_protection ~= true then
minetest.set_node(pos, {name = "tnt:boom"})
end
local sound = def.sound or "tnt_explode"
minetest.sound_play(sound, {pos = pos, gain = 2.5,
max_hear_distance = math.min(def.radius * 20, 128)}, true)
local drops, radius = tnt_explode(pos, def.radius, def.ignore_protection,
def.ignore_on_blast, owner, def.explode_center)
def.ignore_on_blast, owner)
-- append entity drops
local damage_radius = (radius / math.max(1, def.radius)) * def.damage_radius
entity_physics(pos, damage_radius, drops)