Skip to content


Keys: Fix crash when using unconfigured default:key
Browse files Browse the repository at this point in the history
Since meta secret field is blank on any keys (default:key) obtained using
/give, the game will crash if you attempt to use one of these. This follows
along the principle that the game should never have any reason to crash.
  • Loading branch information
octacian authored and paramat committed Mar 17, 2017
1 parent 6821296 commit 07e1142
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mods/default/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

key_meta:set_string("secret", minetest.parse_json(key_oldmeta).secret)

Expand Down

0 comments on commit 07e1142

Please sign in to comment.