mirror of
https://github.com/louisroyer/minetest-toolranks-extras.git
synced 2024-09-28 15:50:57 +02:00
Add dugnodes on hoe uses
This commit is contained in:
parent
d4bdd89117
commit
23006c1ab9
15
hoe.lua
15
hoe.lua
@ -1,10 +1,23 @@
|
|||||||
local function add_hoe(material)
|
local function add_hoe(material)
|
||||||
local name = "farming:hoe_"..material
|
local name = "farming:hoe_"..material
|
||||||
local desc = ItemStack(name):get_definition().description
|
local desc = ItemStack(name):get_definition().description
|
||||||
|
local hoe_on_use = ItemStack(name):get_definition().on_use
|
||||||
minetest.override_item(name, {
|
minetest.override_item(name, {
|
||||||
original_description = desc,
|
original_description = desc,
|
||||||
description = toolranks.create_description(desc, 0, 1),
|
description = toolranks.create_description(desc, 0, 1),
|
||||||
after_use = toolranks.new_afteruse
|
after_use = toolranks.new_afteruse,
|
||||||
|
-- we also want hoes to increase dugnodes when farming soil
|
||||||
|
on_use = function(itemstack, user, pointed_thing, uses)
|
||||||
|
local wear = itemstack:get_wear()
|
||||||
|
local ret_itemstack = hoe_on_use(itemstack, user, pointed_thing, uses)
|
||||||
|
local hoe_uses = ret_itemstack and ret_itemstack:get_wear() - wear or 0
|
||||||
|
if (hoe_uses > 0) then -- increase dugnode if tool damaged
|
||||||
|
return toolranks.new_afteruse(ret_itemstack, user, nil, {wear = hoe_uses})
|
||||||
|
else
|
||||||
|
return ret_itemstack or nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user