summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorh-v-smacker <hans-von-smacker+github@gmail.com>2018-10-25 12:19:06 +0300
committerh-v-smacker <hans-von-smacker+github@gmail.com>2018-10-25 12:19:06 +0300
commit7eed764e9ccd126be28307091e2472a9b728a3b6 (patch)
tree12949bbd5f2169cd5d9c020af7b1fc0c5c9e17f5
parent93f8901ceb83adc0dad98565c05c813c9c5f8665 (diff)
barrels honor area protection
-rw-r--r--nodes_barrel.lua20
1 files changed, 14 insertions, 6 deletions
diff --git a/nodes_barrel.lua b/nodes_barrel.lua
index 5d5da17..e6b4e4b 100644
--- a/nodes_barrel.lua
+++ b/nodes_barrel.lua
@@ -26,6 +26,7 @@ local S = cottages.S
barrel = {};
+--- 50 bucket barrels
local barrel_max = 50
local liquids = {
@@ -81,7 +82,7 @@ barrel.on_construct = function( pos )
end
--- can only be digged if there are no more vessels/buckets in any of the slots
+-- can only be dug if there are no more vessels/buckets in any of the slots
-- TODO: allow digging of a filled barrel? this would disallow stacking of them
barrel.can_dig = function( pos, player )
local meta = minetest.get_meta(pos);
@@ -99,11 +100,15 @@ barrel.can_dig = function( pos, player )
end
--- allow to put into "pour": if barrel is empty or has the same type AND we know the bucket type
+-- allow to put into "pour": if barrel is empty OR has the same type AND we know the bucket type AND the barrel is not full
-- allow to put into "fill": if empty bucket and barrel is not empty
barrel.allow_metadata_inventory_put = function(pos, listname, index, stack, player)
+
+ if minetest.is_protected(pos, player:get_player_name()) then
+ return 0
+ end
+
local iname = stack:get_name()
-
local meta = minetest.get_meta(pos)
if listname == "input" then
@@ -146,6 +151,10 @@ end
-- the barrel received input; either a new liquid that is to be poured in or a vessel that is to be filled
barrel.on_metadata_inventory_put = function( pos, listname, index, stack, player )
+ if minetest.is_protected(pos, player:get_player_name()) then
+ return
+ end
+
local iname = stack:get_name()
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
@@ -191,7 +200,6 @@ barrel.on_metadata_inventory_put = function( pos, listname, index, stack, player
end
-
end
-- Barrels: default = open = empty // closed = has contents
@@ -242,7 +250,7 @@ minetest.register_node("cottages:barrel_open", {
-- horizontal barrel
minetest.register_node("cottages:barrel_lying", {
- description = S("Barrel (closed), lying somewhere"),
+ description = S("Barrel (closed), lying on its side"),
paramtype = "light",
paramtype2 = "wallmounted",
drawtype = "mesh",
@@ -263,7 +271,7 @@ minetest.register_node("cottages:barrel_lying", {
-- horizontal barrel, open
minetest.register_node("cottages:barrel_lying_open", {
- description = S("Barrel (opened), lying somewhere"),
+ description = S("Barrel (opened), lying on its side"),
paramtype = "light",
paramtype2 = "wallmounted",
drawtype = "mesh",