Keys: Update default.can_interact_with_node to new item meta

Completes a forgotten update in 9d3a526
This commit is contained in:
SmallJoker 2017-03-12 14:03:37 +01:00 committed by Auke Kok
parent 07a5fca432
commit b87ef5ccde
3 changed files with 17 additions and 13 deletions

@ -551,21 +551,23 @@ function default.can_interact_with_node(player, pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
-- is player wielding the right key? if player:get_player_name() == meta:get_string("owner") then
local item = player:get_wielded_item() -- Owner can access the node to any time
if item:get_name() == "default:key" then
local key_meta = minetest.parse_json(item:get_metadata())
local secret = meta:get_string("key_lock_secret")
if secret ~= key_meta.secret then
return false
end
return true return true
end end
if player:get_player_name() ~= meta:get_string("owner") then -- is player wielding the right key?
return false local item = player:get_wielded_item()
if item:get_name() == "default:key" then
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)
item:set_metadata("")
end
return meta:get_string("key_lock_secret") == key_meta:get_string("secret")
end end
return true return false
end end

@ -1805,6 +1805,7 @@ minetest.register_node("default:chest_locked", {
if key_meta:get_string("secret") == "" then if key_meta:get_string("secret") == "" then
key_meta:set_string("secret", minetest.parse_json(itemstack:get_metadata()).secret) key_meta:set_string("secret", minetest.parse_json(itemstack:get_metadata()).secret)
itemstack:set_metadata("")
end end
if secret ~= key_meta:get_string("secret") then if secret ~= key_meta:get_string("secret") then

@ -149,6 +149,7 @@ function _doors.door_toggle(pos, node, clicker)
if key_meta:get_string("secret") == "" then if key_meta:get_string("secret") == "" then
key_meta:set_string("secret", minetest.parse_json(item:get_metadata()).secret) key_meta:set_string("secret", minetest.parse_json(item:get_metadata()).secret)
item:set_metadata("")
end end
if secret ~= key_meta:get_string("secret") then if secret ~= key_meta:get_string("secret") then