summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHybridDog <adresse_test@t-online.de>2015-05-22 18:38:08 +0200
committerAuke Kok <sofar@foo-projects.org>2015-05-25 15:48:07 -0700
commitf3aed139d68e12e2ceda2abd107386a23dbaf047 (patch)
tree968afb31aa19f7b3fa424f370a074f10c976d945
parentc210807fe440522bd2d368e22db26ecd8686aaf3 (diff)
allow filling the watercan with e.g. river water.
I didn't merge the part that would reject filling a watercan in areas you are protected from editing. It would make more sense if this was allowed, since the water block used to fill is not consumed. Also, I'd rather see code making sure that other people's plants can't be overwatered, which is more dangereous and I've not checked if that is possible now.
-rw-r--r--init.lua14
1 files changed, 5 insertions, 9 deletions
diff --git a/init.lua b/init.lua
index 2e107bb..7382d2d 100644
--- a/init.lua
+++ b/init.lua
@@ -214,24 +214,21 @@ minetest.register_tool("crops:watering_can", {
tool_capabilities = {},
on_use = function(itemstack, user, pointed_thing)
local pos = pointed_thing.under
- local ppos = pos
- if pos == nil then
+ if not pos then
return itemstack
end
-- filling it up?
local node = minetest.get_node(pos)
- if node.name == "default:water_source" or
- node.name == "default:water_flowing" then
+ if minetest.get_item_group(node.name, "water") >= 3 then
itemstack:set_wear(1)
return itemstack
end
-- using it on a top-half part of a plant?
local meta = minetest.get_meta(pos)
if meta:get_int("crops_top_half") == 1 then
- pos = {x = pos.x, y = pos.y - 1, z = pos.z}
+ meta = minetest.get_meta({x=pos.x, y=pos.y-1, z=pos.z})
end
-- using it on a plant?
- local meta = minetest.get_meta(pos)
local water = meta:get_int("crops_water")
if water == nil then
return itemstack
@@ -260,16 +257,15 @@ minetest.register_tool("crops:hydrometer", {
},
on_use = function(itemstack, user, pointed_thing)
local pos = pointed_thing.under
- if pos == nil then
+ if not pos then
return itemstack
end
-- doublesize plant?
local meta = minetest.get_meta(pos)
if meta:get_int("crops_top_half") == 1 then
- pos = {x = pos.x, y = pos.y - 1, z = pos.z}
+ meta = minetest.get_meta({x=pos.x, y=pos.y-1, z=pos.z})
end
- local meta = minetest.get_meta(pos)
-- using it on a plant?
local water = meta:get_int("crops_water")
if water == nil then