Remove sound argument from tnt.explode, update API

This commit is contained in:
Wuzzy 2022-08-07 20:59:17 +02:00
parent 51fc9e7ac9
commit 0500e22a18
2 changed files with 14 additions and 16 deletions

View File

@ -16,13 +16,14 @@ Note: The `igniter` is only used for logging purposes.
## `tnt.boom(pos, radius, sound)` ## `tnt.boom(pos, radius, sound)`
High-level TNT explosion. Blows up a TNT node.
Immediately blows up a TNT node at `pos`, This will remove the TNT node, cause an explosion at `pos`,
removes nodes, drops items, damages entities, spawns particles. removes nodes around it, drops items, damages entities, spawns particles
and plays a sound effect.
Parameters: Parameters:
* `pos`: Position of TNT node. The TNT node is required! * `pos`: Position of the TNT node. The TNT node is required!
* `radius`: Explosion radius (default: read from `tnt_radius` setting) * `radius`: Explosion radius (default: read from `tnt_radius` setting)
* `sound`: Sound name for explosion (default: `tnt_explode`) * `sound`: Sound name for explosion (default: `tnt_explode`)
@ -30,8 +31,8 @@ Parameters:
## `tnt.boom_notnt(pos, radius, sound, remove_nodes)` ## `tnt.boom_notnt(pos, radius, sound, remove_nodes)`
High-level explosion. Does an explosion.
Same as `tnt.boom` but works at any position. No TNT required. Same as `tnt.boom` but works for non-TNT nodes as well. No TNT required.
Parameters: Parameters:
@ -41,14 +42,12 @@ Parameters:
* `remove_nodes`: If true, will remove nodes, otherwise won't. (default: false) * `remove_nodes`: If true, will remove nodes, otherwise won't. (default: false)
## `tnt.explode(pos, radius, sound)` ## `tnt.explode(pos, radius)`
Low-level explosion. Low-level explosion.
Immediately removes and drops nodes at `pos` Does a "raw" explosion that only removes nodes and drops items.
with a radius `radius` and plays a `sound`. There are no particle effects, sounds, entity damage or anything else.
There are no particle effects nor is ther entity damage or Useful if you want to customize the explosion effects.
anything else.
* `pos`: Center of the explosion * `pos`: Center of the explosion
* `radius`: Explosion radius * `radius`: Explosion radius (NO default value!)
* `sound`: Explosion sound (NOT optional)

View File

@ -208,9 +208,7 @@ end
-- TNT ground removal -- TNT ground removal
function tnt.explode(pos, radius, sound) function tnt.explode(pos, radius)
play_tnt_sound(pos, sound)
local pos = vector.round(pos) local pos = vector.round(pos)
local vm = VoxelManip() local vm = VoxelManip()
local pr = PseudoRandom(os.time()) local pr = PseudoRandom(os.time())
@ -259,6 +257,7 @@ local function rawboom(pos, radius, sound, remove_nodes, is_tnt)
end end
if remove_nodes then if remove_nodes then
local drops = tnt.explode(pos, tnt_radius, sound) local drops = tnt.explode(pos, tnt_radius, sound)
play_tnt_sound(pos, sound)
if is_tnt then if is_tnt then
minetest.log("action", "[rp_tnt] TNT exploded at "..minetest.pos_to_string(pos, 0)) minetest.log("action", "[rp_tnt] TNT exploded at "..minetest.pos_to_string(pos, 0))
else else