forked from mtcontrib/farming
Can only hoe top of soil (thanks HybridDog for this idea), breaking sound added to hoe
This commit is contained in:
parent
02d10c376e
commit
a1d3e41b1f
4
api.txt
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
|
inventory_image = "unknown_item.png", -- Image to be used as wield- and inventory image
|
||||||
max_uses = 30, -- Uses until destroyed
|
max_uses = 30, -- Uses until destroyed
|
||||||
material = "", -- Material for recipes
|
material = "", -- Material for recipes
|
||||||
@ -35,7 +35,7 @@ The farming API allows you to easily register plants and hoes.
|
|||||||
### Plant definition
|
### 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
|
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
|
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)
|
-- ^ Always provide a plant texture for each step, format: modname_plantname_i.png (i = stepnumber)
|
||||||
|
13
hoes.lua
13
hoes.lua
@ -63,8 +63,9 @@ function farming.hoe_on_use(itemstack, user, pointed_thing, uses)
|
|||||||
|
|
||||||
local pt = pointed_thing
|
local pt = pointed_thing
|
||||||
|
|
||||||
-- check if pointing at a node
|
-- am I going to hoe the top of a dirt node?
|
||||||
if not pt or pt.type ~= "node" then
|
if not pt or pt.type ~= "node"
|
||||||
|
or pt.above.y ~= pt.under.y + 1 then
|
||||||
return
|
return
|
||||||
end
|
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})
|
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 farming.is_creative(user:get_player_name()) then
|
||||||
if tr then
|
if tr then
|
||||||
@ -116,6 +118,11 @@ function farming.hoe_on_use(itemstack, user, pointed_thing, uses)
|
|||||||
itemstack:add_wear(wear)
|
itemstack:add_wear(wear)
|
||||||
end
|
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
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user