Permalink
Browse files

Keys: Update default.can_interact_with_node to new item meta

Completes a forgotten update in 9d3a526
  • Loading branch information...
SmallJoker authored and sofar committed Mar 12, 2017
1 parent 07a5fca commit b87ef5ccde9cfa9096cae1e27774a9c386399b00
Showing with 15 additions and 11 deletions.
  1. +13 −11 mods/default/functions.lua
  2. +1 −0 mods/default/nodes.lua
  3. +1 −0 mods/doors/init.lua
View
@@ -551,21 +551,23 @@ function default.can_interact_with_node(player, pos)
local meta = minetest.get_meta(pos)
if player:get_player_name() == meta:get_string("owner") then
-- Owner can access the node to any time
return true
end
-- is player wielding the right key?
local item = player:get_wielded_item()
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
local key_meta = item:get_meta()
return true
end
if key_meta:get_string("secret") == "" then
key_meta:set_string("secret", minetest.parse_json(item:get_metadata()).secret)
item:set_metadata("")
end
if player:get_player_name() ~= meta:get_string("owner") then
return false
return meta:get_string("key_lock_secret") == key_meta:get_string("secret")
end
return true
end
return false
end
View
@@ -1805,6 +1805,7 @@ minetest.register_node("default:chest_locked", {
if key_meta:get_string("secret") == "" then
key_meta:set_string("secret", minetest.parse_json(itemstack:get_metadata()).secret)
itemstack:set_metadata("")
end
if secret ~= key_meta:get_string("secret") then
View
@@ -149,6 +149,7 @@ function _doors.door_toggle(pos, node, clicker)
if key_meta:get_string("secret") == "" then
key_meta:set_string("secret", minetest.parse_json(item:get_metadata()).secret)
item:set_metadata("")
end
if secret ~= key_meta:get_string("secret") then

5 comments on commit b87ef5c

@Thomas--S

This comment has been minimized.

Contributor

Thomas--S replied Mar 12, 2017

I think that parts of this were included in #1580

@SmallJoker

This comment has been minimized.

Member

SmallJoker replied Mar 12, 2017

I'm sorry, I didn't notice that you had the same fix in your doors pull. However, this here is just a quick fix, thus rebasing shouldn't be much a problem for #1580.

@Thomas--S

This comment has been minimized.

Contributor

Thomas--S replied Mar 12, 2017

It's ok. I hope #1580 will be merged soon, as I don't want to rebase it a third time 😉

@Fixer-007

This comment has been minimized.

Contributor

Fixer-007 replied Mar 12, 2017

Don't forget about steel trapdoor!

@Thomas--S

This comment has been minimized.

Contributor

Thomas--S replied Mar 13, 2017

@Fixer-007 Steel doors will use the default.can_interact_with_node() function after #1580 gets merged.

Please sign in to comment.