diff options
author | TenPlus1 <kinsellaja@yahoo.com> | 2017-05-20 09:01:00 +0100 |
---|---|---|
committer | TenPlus1 <kinsellaja@yahoo.com> | 2017-05-20 09:01:00 +0100 |
commit | 20c6d2b9b95d88cc50aea6541493076f11b2b148 (patch) | |
tree | 66fa6b3ee062ab4b830bffbc29aae07003e99ba0 | |
parent | cbf72118d9eed3de00aeaba5212750dae428b482 (diff) |
added extra protection to chest
-rw-r--r-- | doors_chest.lua | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/doors_chest.lua b/doors_chest.lua index 89aaf54..054797d 100644 --- a/doors_chest.lua +++ b/doors_chest.lua @@ -529,6 +529,39 @@ minetest.register_node("protector:chest", { player:get_player_name(), minetest.pos_to_string(pos))) end, + on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + + minetest.log("action", S("@1 moves stuff inside protected chest at @2", + player:get_player_name(), minetest.pos_to_string(pos))) + end, + + allow_metadata_inventory_put = function(pos, listname, index, stack, player) + + if minetest.is_protected(pos, player:get_player_name()) then + return 0 + end + + return stack:get_count() + end, + + allow_metadata_inventory_take = function(pos, listname, index, stack, player) + + if minetest.is_protected(pos, player:get_player_name()) then + return 0 + end + + return stack:get_count() + end, + + allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) + + if minetest.is_protected(pos, player:get_player_name()) then + return 0 + end + + return count + end, + on_rightclick = function(pos, node, clicker) if minetest.is_protected(pos, clicker:get_player_name()) then @@ -575,6 +608,11 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) local pos_s = string.sub(formname,string.len("protector:chest_") + 1) local pos = minetest.string_to_pos(pos_s) + + if minetest.is_protected(pos, player:get_player_name()) then + return + end + local meta = minetest.get_meta(pos) ; if not meta then return end local chest_inv = meta:get_inventory() ; if not chest_inv then return end local player_inv = player:get_inventory() |