diff --git a/DEVELOPERS.md b/DEVELOPERS.md index 4d8f634..77c2c9a 100644 --- a/DEVELOPERS.md +++ b/DEVELOPERS.md @@ -54,6 +54,7 @@ Mods with documented APIs: * `rp_player_effects`: Add player effects (required if you want to modify player physics) * `rp_sounds`: Node sounds * `rp_util`: Helper functions for Repixture +* `rp_tnt`: Ignite and blow up TNT, also spawn TNT-less explosions * `tt`: Custom tooltips Beware: Calling functions that are not documented are NOT guaranted to be stable diff --git a/mods/rp_tnt/API.md b/mods/rp_tnt/API.md new file mode 100644 index 0000000..ef6b612 --- /dev/null +++ b/mods/rp_tnt/API.md @@ -0,0 +1,54 @@ +# `rp_tnt` API + +This file documents the functions available for developers in this mod. + + +## `tnt.burn(pos, igniter)` + +Ignite TNT at `pos`. + +* `pos`: Position of TNT node +* `igniter`: Optional player object of player who ignited it or `nil` if nobody/unknown + +Note: The `igniter` is only used for logging purposes. + + + +## `tnt.boom(pos, radius, sound)` + +High-level TNT explosion. +Immediately blows up a TNT node at `pos`, +removes nodes, drops items, damages entities, spawns particles. + +Parameters: + +* `pos`: Position of TNT node. The TNT node is required! +* `radius`: Explosion radius (default: read from `tnt_radius` setting) +* `sound`: Sound name for explosion (default: `tnt_explode`) + + + +## `tnt.boom_notnt(pos, radius, sound, remove_nodes)` + +High-level explosion. +Same as `tnt.boom` but works at any position. No TNT required. + +Parameters: + +* `pos`: Position of the explosion center. +* `radius`: Explosion radius (default: read from `tnt_radius` setting) +* `sound`: Sound name for explosion (default: `tnt_explode`) +* `remove_nodes`: If true, will remove nodes, otherwise won't. (default: false) + + +## `tnt.explode(pos, radius, sound)` + +Low-level explosion. +Immediately removes and drops nodes at `pos` +with a radius `radius` and plays a `sound`. +There are no particle effects nor is ther entity damage or +anything else. + +* `pos`: Center of the explosion +* `radius`: Explosion radius +* `sound`: Explosion sound (NOT optional) diff --git a/mods/rp_tnt/README.txt b/mods/rp_tnt/README.txt index 3f0be27..3a97bf3 100644 --- a/mods/rp_tnt/README.txt +++ b/mods/rp_tnt/README.txt @@ -4,7 +4,12 @@ By PilzAdam and ShadowNinja. Tweaked by Kaadmy and Wuzzy, for Repixture. Adds explodable TNT -Place a block of TNT, then click on it with flint and steel +Place a block of TNT, then punch it with flint and steel. + +Developers: See `API.md` for a function reference. You can ignore and blow up TNT. +You can also create arbitrary explosions. + +## Credits Source code license: LGPLv2.1 Sound license: CC0 diff --git a/mods/rp_tnt/init.lua b/mods/rp_tnt/init.lua index b5ba0ed..4d89eb3 100644 --- a/mods/rp_tnt/init.lua +++ b/mods/rp_tnt/init.lua @@ -180,6 +180,7 @@ local function emit_fuse_smoke(pos) }) end + -- Ignite TNT at pos. -- igniter: Optional player object of player who ignited it or nil if nobody function tnt.burn(pos, igniter) @@ -258,7 +259,11 @@ local function rawboom(pos, radius, sound, remove_nodes, is_tnt) end if remove_nodes then local drops = tnt.explode(pos, tnt_radius, sound) - minetest.log("action", "[rp_tnt] TNT exploded at "..minetest.pos_to_string(pos, 0)) + if is_tnt then + minetest.log("action", "[rp_tnt] TNT exploded at "..minetest.pos_to_string(pos, 0)) + else + minetest.log("action", "[rp_tnt] Explosion at "..minetest.pos_to_string(pos, 0)) + end entity_physics(pos, tnt_radius) eject_drops(drops, pos, tnt_radius) else