minetest-toolranks-extras/hoe.lua

34 lines
1.0 KiB
Lua
Raw Permalink Normal View History

2020-02-12 12:40:48 +01:00
local function add_hoe(material)
local name = "farming:hoe_"..material
local desc = ItemStack(name):get_definition().description
2020-03-07 14:37:47 +01:00
local hoe_on_use = ItemStack(name):get_definition().on_use
2020-02-12 12:40:48 +01:00
minetest.override_item(name, {
original_description = desc,
2020-07-03 02:19:12 +02:00
description = toolranks.create_description(desc),
2020-03-07 14:37:47 +01:00
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
2020-02-12 12:40:48 +01:00
})
end
add_hoe("wood")
add_hoe("stone")
add_hoe("steel")
-- Following hoes are not available in creative inventory, but
-- it is possible to /give them
add_hoe("bronze")
add_hoe("mese")
add_hoe("diamond")