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 to cb_registrar, along with cb.
Example
Code: Select all
local function callback(player, hpchange)
minetest.log("action", player:get_player_name() .. "'s HP changed!\n" ..
"old_hp = " .. player:get_hp() - hpchange .. ",\n" ..
"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)
License
Code: MIT
ContentDB: https://content.minetest.net/packages/A ... lbacks_api
Browse releases: https://github.com/ClobberXD/callbacks_api/releases
Browse code: https://github.com/ClobberXD/callbacks_api
Download latest: https://github.com/ClobberXD/callbacks_ ... master.zip