Module extend_item.lua

📑 Source

Extend callbacks of a registered node by wrapping them.

Allows injecting behavior before/after an existing callback while still optionally calling the original implementation via next. This works on boths nodes and items as it uses core.override_item under the hood.

See also

Usage

extend_item("default:stone", {
  on_punch = function(next, pos, node, puncher, pointed_thing)
    minetest.chat_send_all("Stone punched!")
    if next then
      return next()
    end
  end
})

Functions


# returns... (node_name, extend_def)

Parameters

  • node_name string Name of the node in core.registered_nodes
  • extend_def extend_def Table of callbacks to extend

Returns

    nil