Module extend_item
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.
The provided callback receives next as its first argument. Calling next(...)
will invoke the original callback if it exists.
Functions
| extend_item (node_name, extend_def, extend_def.) | Extend callbacks on a node definition. |
Functions
- extend_item (node_name, extend_def, extend_def.)
-
Extend callbacks on a node definition.
Internally uses
core.override_itemto replace callbacks with wrappers.Parameters:
- node_name
string
Name of the node in
core.registered_nodes - extend_def table Table of callbacks to extend
- extend_def.
function
Replacement callback that receives next as its first parameter followed by the original callback arguments.
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(pos, node, puncher, pointed_thing) end end })
- node_name
string
Name of the node in