From 7176a228eab1f64e1a130444ff633c602e678b08 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Wed, 25 Nov 2015 23:28:01 -0800 Subject: Add sound effect for watering plants. Just a short watering sound, nothing fancy. --- init.lua | 9 +++++---- sounds/crops_watercan_watering.ogg | Bin 0 -> 12317 bytes 2 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 sounds/crops_watercan_watering.ogg diff --git a/init.lua b/init.lua index b8c9d1d..e205f45 100644 --- a/init.lua +++ b/init.lua @@ -105,7 +105,7 @@ crops.plant = function(pos, node) minetest.set_node(pos, node) local meta = minetest.get_meta(pos) local plant = find_plant(node) - meta:set_int("crops_water", plant.properties.waterstart) + meta:set_int("crops_water", max(plant.properties.waterstart, 1)) meta:set_int("crops_damage", 0) end @@ -132,7 +132,7 @@ crops.can_grow = function(pos) end end -- growing costs water! - meta:set_int("crops_water", math.max(0, water - 10)) + meta:set_int("crops_water", math.max(1, water - 10)) -- allow the plant to grow return true @@ -323,7 +323,7 @@ minetest.register_tool("crops:watering_can", { end -- using it on a plant? local water = meta:get_int("crops_water") - if water == nil then + if water < 1 then return itemstack end -- empty? @@ -331,6 +331,7 @@ minetest.register_tool("crops:watering_can", { return itemstack end crops.particles(ppos, 2) + minetest.sound_play("crops_watercan_watering", {pos=pos, gain=0.8}) water = math.min(water + crops.settings.watercan, crops.settings.watercan_max) meta:set_int("crops_water", water) @@ -432,7 +433,7 @@ minetest.register_abm({ water = math.min(100, water + 1) else -- dry out the plant - water = math.max(0, water - plant.properties.wateruse ) + water = math.max(1, water - plant.properties.wateruse) end meta:set_int("crops_water", water) diff --git a/sounds/crops_watercan_watering.ogg b/sounds/crops_watercan_watering.ogg new file mode 100644 index 0000000..f1fc2d5 Binary files /dev/null and b/sounds/crops_watercan_watering.ogg differ -- cgit v1.2.3