12345678910111213141516171819202122232425262728 |
- undiggable_node_api = {}
- --helper function
- local function allow_remove_self(itemstack, user, pointed_thing)
- if pointed_thing.type == "node"
- then
- local node = minetest.get_node(pointed_thing.under)
- if node.name == itemstack:get_name()
- then
- minetest.remove_node(pointed_thing.under)
- end
- end
- end
- --API FUNCTION
- --registers an undiggable node but it can be used as a tool to dig itself
- undiggable_node_api.register_barrier = function(name, definition)
- definition.diggable = false
- definition.on_use = allow_remove_self
- definition.groups = definition.groups or {}
- definition.groups.indestructible = 1
- minetest.register_node(name, definition)
- end
|