Add API documentation for rp_tnt

This commit is contained in:
Wuzzy 2022-08-07 20:49:21 +02:00
parent a3d434de06
commit 51fc9e7ac9
4 changed files with 67 additions and 2 deletions

View File

@ -54,6 +54,7 @@ Mods with documented APIs:
* `rp_player_effects`: Add player effects (required if you want to modify player physics) * `rp_player_effects`: Add player effects (required if you want to modify player physics)
* `rp_sounds`: Node sounds * `rp_sounds`: Node sounds
* `rp_util`: Helper functions for Repixture * `rp_util`: Helper functions for Repixture
* `rp_tnt`: Ignite and blow up TNT, also spawn TNT-less explosions
* `tt`: Custom tooltips * `tt`: Custom tooltips
Beware: Calling functions that are not documented are NOT guaranted to be stable Beware: Calling functions that are not documented are NOT guaranted to be stable

54
mods/rp_tnt/API.md Normal file
View File

@ -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)

View File

@ -4,7 +4,12 @@ By PilzAdam and ShadowNinja.
Tweaked by Kaadmy and Wuzzy, for Repixture. Tweaked by Kaadmy and Wuzzy, for Repixture.
Adds explodable TNT 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 Source code license: LGPLv2.1
Sound license: CC0 Sound license: CC0

View File

@ -180,6 +180,7 @@ local function emit_fuse_smoke(pos)
}) })
end end
-- Ignite TNT at pos. -- Ignite TNT at pos.
-- igniter: Optional player object of player who ignited it or nil if nobody -- igniter: Optional player object of player who ignited it or nil if nobody
function tnt.burn(pos, igniter) function tnt.burn(pos, igniter)
@ -258,7 +259,11 @@ 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)
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
minetest.log("action", "[rp_tnt] Explosion at "..minetest.pos_to_string(pos, 0))
end
entity_physics(pos, tnt_radius) entity_physics(pos, tnt_radius)
eject_drops(drops, pos, tnt_radius) eject_drops(drops, pos, tnt_radius)
else else