diff --git a/api.txt b/api.txt index acec5a0..81092c6 100644 --- a/api.txt +++ b/api.txt @@ -21,7 +21,7 @@ The farming API allows you to easily register plants and hoes. { - description = "", -- Description for tooltip + description = "My Hoe", -- Description for tooltip inventory_image = "unknown_item.png", -- Image to be used as wield- and inventory image max_uses = 30, -- Uses until destroyed material = "", -- Material for recipes @@ -35,7 +35,7 @@ The farming API allows you to easily register plants and hoes. ### Plant definition { - description = "", -- Description of seed item + description = "My Plant", -- Description of seed item inventory_image = "unknown_item.png", -- Image to be used as seed's wield- and inventory image steps = 8, -- How many steps the plant has to grow, until it can be harvested -- ^ Always provide a plant texture for each step, format: modname_plantname_i.png (i = stepnumber) diff --git a/hoes.lua b/hoes.lua index 5716128..fc7823d 100644 --- a/hoes.lua +++ b/hoes.lua @@ -63,8 +63,9 @@ function farming.hoe_on_use(itemstack, user, pointed_thing, uses) local pt = pointed_thing - -- check if pointing at a node - if not pt or pt.type ~= "node" then + -- am I going to hoe the top of a dirt node? + if not pt or pt.type ~= "node" + or pt.above.y ~= pt.under.y + 1 then return end @@ -100,7 +101,8 @@ function farming.hoe_on_use(itemstack, user, pointed_thing, uses) minetest.sound_play("default_dig_crumbly", {pos = pt.under, gain = 0.5}) - local wear = 65535 / (uses -1) + local wdef = itemstack:get_definition() + local wear = 65535 / (uses - 1) if farming.is_creative(user:get_player_name()) then if tr then @@ -116,6 +118,11 @@ function farming.hoe_on_use(itemstack, user, pointed_thing, uses) itemstack:add_wear(wear) end + if itemstack:get_count() == 0 and wdef.sound and wdef.sound.breaks then + minetest.sound_play(wdef.sound.breaks, {pos = pt.above, + gain = 0.5}, true) + end + return itemstack end