diff --git a/mods/default/functions.lua b/mods/default/functions.lua index eeac0c2..bf3749a 100644 --- a/mods/default/functions.lua +++ b/mods/default/functions.lua @@ -562,7 +562,12 @@ function default.can_interact_with_node(player, pos) local key_meta = item:get_meta() if key_meta:get_string("secret") == "" then - key_meta:set_string("secret", minetest.parse_json(item:get_metadata()).secret) + local key_oldmeta = item:get_metadata() + if key_oldmeta == "" or not minetest.parse_json(key_oldmeta) then + return false + end + + key_meta:set_string("secret", minetest.parse_json(key_oldmeta).secret) item:set_metadata("") end