Callbacks API

Image placeholder

Description

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 to cb_registrar, along with cb.

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)

Reviews

Review

Do you recommend this mod?

  • No reviews, yet.

Releases

All releases

Threads

New thread

Thread Last Reply

No threads found

Information

Provides

callbacks_api

Dependencies

Required
No required dependencies

Information

Type
Mod
Technical Name
callbacks_api
Languages
English
License
MIT for code,
CC0-1.0 for media.
Maintenance State
As-Is
Added
2019-05-04 10:45 UTC
Maintainers
ANAND