summaryrefslogtreecommitdiff
path: root/technic_chests/common.lua
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-03-07 11:09:13 -0500
committerGitHub <noreply@github.com>2017-03-07 11:09:13 -0500
commitb4659d9356d0c303ae750f153081481e9cd89536 (patch)
treee9259f1bc9f804685d4cb472d80264c79e9a7d71 /technic_chests/common.lua
parent186f9b70ac9efef4a1672f6822e6c22d31928dc4 (diff)
parentec6354b6a5f5fcb5a974c1c687f4c4b9ba603f27 (diff)
Merge pull request #317 from Thomas--S/chest-bugfix
Update chests protection to current minetest_game
Diffstat (limited to 'technic_chests/common.lua')
-rw-r--r--technic_chests/common.lua47
1 files changed, 7 insertions, 40 deletions
diff --git a/technic_chests/common.lua b/technic_chests/common.lua
index b8e30a4..32b34eb 100644
--- a/technic_chests/common.lua
+++ b/technic_chests/common.lua
@@ -26,12 +26,7 @@ technic.chests.can_dig = function(pos, player)
end
local function inv_change(pos, count, player)
- local meta = minetest.get_meta(pos)
- if not has_locked_chest_privilege(meta, player) then
- minetest.log("action", player:get_player_name()..
- " tried to access a locked chest belonging to "..
- meta:get_string("owner").." at "..
- minetest.pos_to_string(pos))
+ if not default.can_interact_with_node(player, pos) then
return 0
end
return count
@@ -54,42 +49,14 @@ function technic.chests.on_inv_move(pos, from_list, from_index, to_list, to_inde
end
function technic.chests.on_inv_put(pos, listname, index, stack, player)
- minetest.log("action", player:get_player_name()..
- " puts stuff in to chest at "
- ..minetest.pos_to_string(pos))
+ minetest.log("action", player:get_player_name() ..
+ " moves " .. stack:get_name() ..
+ " to chest at " .. minetest.pos_to_string(pos))
end
function technic.chests.on_inv_take(pos, listname, index, stack, player)
- minetest.log("action", player:get_player_name()..
- " takes stuff from chest at "
- ..minetest.pos_to_string(pos))
-end
-
-local function has_locked_chest_privilege(meta, player)
- if player then
- if minetest.check_player_privs(player, "protection_bypass") then
- return true
- end
- else
- return false
- 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
-
- return true
- end
-
- if player:get_player_name() ~= meta:get_string("owner") then
- return false
- end
-
- return true
+ minetest.log("action", player:get_player_name() ..
+ " takes " .. stack:get_name() ..
+ " from chest at " .. minetest.pos_to_string(pos))
end