Browse Source

Can only hoe top of soil (thanks HybridDog for this idea), breaking sound added to hoe

master
TenPlus1 2 years ago
parent
commit
a1d3e41b1f
  1. 4
      api.txt
  2. 13
      hoes.lua

4
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)

13
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

Loading…
Cancel
Save