From 7cc00605cbfc9a1412d36ef7c7d15eafafbdf839 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sun, 22 Sep 2019 05:26:12 +0200 Subject: [PATCH] Don't crack things that are already cracked --- mods/locks/init.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mods/locks/init.lua b/mods/locks/init.lua index f5fbff1..f92512f 100644 --- a/mods/locks/init.lua +++ b/mods/locks/init.lua @@ -67,10 +67,15 @@ minetest.register_tool( if minetest.get_item_group(node.name, "locked") == 0 then return itemstack end + local meta = minetest.get_meta(pos) + local cracked = meta:get_int("lock_cracked") == 1 + if cracked then + -- Is already open + return itemstack + end -- Attempt to pick lock if math.random(1, 5) <= 1 then -- Success! - local meta = minetest.get_meta(pos) meta:set_int("lock_cracked", 1) local timer = minetest.get_node_timer(pos) -- Unlock node for a limited time