From c7045bc415b680ae67b050b733a1f2e1b1a4350a Mon Sep 17 00:00:00 2001 From: cora Date: Tue, 13 Sep 2022 02:57:24 +0200 Subject: [PATCH] Instadig nodes on punch in (gamemode) creative --- mods/HUD/mcl_inventory/init.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mods/HUD/mcl_inventory/init.lua b/mods/HUD/mcl_inventory/init.lua index 86670a8b3..895ccd811 100644 --- a/mods/HUD/mcl_inventory/init.lua +++ b/mods/HUD/mcl_inventory/init.lua @@ -196,6 +196,7 @@ local mt_is_creative_enabled = minetest.is_creative_enabled function minetest.is_creative_enabled(name) if mt_is_creative_enabled(name) then return true end + if not name then return false end local p = minetest.get_player_by_name(name) if p then return p:get_meta():get_string("gamemode") == "creative" @@ -203,6 +204,20 @@ function minetest.is_creative_enabled(name) return false end +--Insta "digging" nodes in gamemode-creative +minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing) + if minetest.is_creative_enabled() then return end + local name = puncher:get_player_name() + if not minetest.is_creative_enabled(name) then return end + if pointed_thing.type ~= "node" then return end + local def = minetest.registered_nodes[node.name] + if def then + if def.on_destruct then def.on_destruct(pos) end + minetest.remove_node(pos) + return true + end +end) + local function in_table(n,h) for k,v in pairs(h) do if v == n then return true end