diff --git a/api.txt b/api.txt index 0098624..acec5a0 100644 --- a/api.txt +++ b/api.txt @@ -56,3 +56,9 @@ growth_check = function(pos, node_name) end return true -- condition not met, skip next growth stage until next check end, + +### Scythe items that will not drop + +This is a function to add items to a list that scythes will not drop, e.g. farming:trellis or farming:beanpole. + +farming.add_to_scythe_not_drops(item_name) diff --git a/hoes.lua b/hoes.lua index bd440a5..6417582 100644 --- a/hoes.lua +++ b/hoes.lua @@ -333,6 +333,12 @@ minetest.register_craftitem("farming:hoe_bomb", { -- Mithril Scythe (special item) +farming.scythe_not_drops = {"farming:trellis", "farming:beanpole"} + +farming.add_to_scythe_not_drops = function(item) + table.insert(farming.scythe_not_drops, item) +end + minetest.register_tool("farming:scythe_mithril", { description = S("Mithril Scythe (Right-click crop to harvest and replant)"), inventory_image = "farming_scythe_mithril.png", @@ -402,8 +408,15 @@ minetest.register_tool("farming:scythe_mithril", { -- add dropped items for _, dropped_item in pairs(drops) do - if dropped_item ~= "farming:trellis" - and dropped_item ~= "farming:beanpole" then + -- dont drop items on this list + for _, not_item in pairs(farming.scythe_not_drops) do + + if dropped_item == not_item then + dropped_item = nil + end + end + + if dropped_item then local obj = minetest.add_item(pos, dropped_item)