TNT: Add tnt.boom defaults
authortenplus1 <tenplus1@users.noreply.github.com>
Thu, 28 Sep 2017 14:18:52 +0000 (15:18 +0100)
committerparamat <mat.gregory@virginmedia.com>
Tue, 10 Oct 2017 21:55:49 +0000 (22:55 +0100)
This adds def, def.radius and def.damage_radius defaults to the
tnt.boom() function if they aren't specified on call.

game_api.txt
mods/tnt/init.lua

index c4dbd78e9bb7a26e417797166b8da7967a28ddd8..1a0e252a652ae3607defe7b87648c91a67c7d54d 100644 (file)
@@ -358,7 +358,7 @@ TNT API
   * `bottom` Bottom tile. By default the name of the tnt with a suffix of `_bottom.png`.
   * `burning` Top tile when lit. By default the name of the tnt with a suffix of `_top_burning_animated.png".
 
-`tnt.boom(position, definition)`
+`tnt.boom(position[, definition])`
 
 ^ Create an explosion.
 
index f3e22fdb0d7cb42f8789962bcd9c9d6609186a42..133431c73f2298cd55e234a709bb29f69804e459 100644 (file)
@@ -387,6 +387,9 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owne
 end
 
 function tnt.boom(pos, def)
+       def = def or {}
+       def.radius = def.radius or 1
+       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 then