Mod
Callbacks API
callbacks_api is a framework for registering callbacks if the callback registration function exists, else returns gracefully.
callbacks_api
callbacks_api is a framework for registering callbacks if the callback registration function exists, else returning gracefully. This mod can be very handy when developing or prototyping new callbacks, either within a mod, or within Minetest itself.
callbacks_api.register_callback(cb_registrar, cb, ...)
Register callback cb (along with optional arguments ...) to cb_registrar, if it exists, or return gracefully.
Parameters
cb_registrar[function]: The function that registers the callback.cb[function]: The callback itself....[Comma-separated arguments]: Optional arguments to pass tocb_registrar, along withcb.
Examples
local function callback(player, hpchange)
minetest.log("action", player:get_player_name() .. "'s HP changed!
" ..
"old_hp = " .. player:get_hp() - hpchange .. ",
" ..
"new_hp = " .. player:get_hp())
end
-- cb_registrar = minetest.register_on_player_hpchange
-- cb = callback
-- ... = false
callbacks_api.register_callback(minetest.register_on_player_hpchange, callback, false) Links
- Source: https://github.com/ClobberXD/callbacks_api
- Forum: https://forum.luanti.org/viewtopic.php?t=22378
- Issues: https://github.com/ClobberXD/callbacks_api/issues
- Original ContentDB page: content.luanti.org/packages/ANAND/callbacks_api/
License
MIT
Media license: CC0-1.0
Development state
AS_IS
| Version | Date | Min engine | Size | Download |
|---|---|---|---|---|
| v1.0 | 2019-05-04 10:46:24 | 1.7 KB | Download |