Skip to content

Commit bb08429

Browse files
tenplus1paramat
authored andcommittedAug 18, 2017
TNT: Allow a custom explosion sound to be used
1 parent 20687a6 commit bb08429

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
 

‎game_api.txt

+1
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ TNT API
348348
* `description` A description for your TNT.
349349
* `radius` The radius within which the TNT can destroy nodes. The default is 3.
350350
* `damage_radius` The radius within which the TNT can damage players and mobs. By default it is twice the `radius`.
351+
* `sound` The sound played when explosion occurs. By default it is `tnt_explode`.
351352
* `disable_drops` Disable drops. By default it is set to false.
352353
* `ignore_protection` Don't check `minetest.is_protected` before removing a node.
353354
* `ignore_on_blast` Don't call `on_blast` even if a node has one.

‎mods/tnt/init.lua

+3-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,9 @@ end
384384
function tnt.boom(pos, def)
385385
local meta = minetest.get_meta(pos)
386386
local owner = meta:get_string("owner")
387-
minetest.sound_play("tnt_explode", {pos = pos, gain = 1.5, max_hear_distance = 2*64})
387+
local sound = def.sound or "tnt_explode"
388+
minetest.sound_play(sound, {pos = pos, gain = 1.5,
389+
max_hear_distance = math.min(def.radius * 20, 128)})
388390
minetest.set_node(pos, {name = "tnt:boom"})
389391
local drops, radius = tnt_explode(pos, def.radius, def.ignore_protection,
390392
def.ignore_on_blast, owner)

0 commit comments

Comments
 (0)
Please sign in to comment.