diff --git a/init.lua b/init.lua index c382bc1..36d47ea 100644 --- a/init.lua +++ b/init.lua @@ -50,26 +50,29 @@ local add_fruit_regrowable = function(fruit, node, leaves) end end - -- override fruit - minetest.override_item(node, { - groups = groups, -- make sure (moretrees) fruits don't fall on dig - after_place_node = function(pos, placer) -- make sure (moretrees and plumtree) fruits aren't placed by player - if placer:is_player() and node == "plumtree:plum" then - minetest.set_node(pos, {name = node, param2 = 0}) - elseif placer:is_player() then - minetest.set_node(pos, {name = node, param2 = 1}) - end - end, - on_dig = minetest.node_dig, -- override on_dig functions causing regrowth not to work - after_dig_node = function(pos, oldnode, oldmetadata, digger) - if oldnode.param2 == 0 and oldnode.name ~= "plumtree:plum" - or oldnode.name == "plumtree:plum" and oldnode.param2 == 1 - or oldnode.name == "cacaotree:pod" then - minetest.set_node(pos, {name = "regrowing_fruits:"..fruit.."_mark", param2 = oldnode.param2}) - minetest.get_node_timer(pos):start(math.random(300, 1500)) - end - end, - }) + -- wait until mods are loaded to ensure that other mods do not override overrides + minetest.register_on_mods_loaded(function() + -- override fruit + minetest.override_item(node, { + groups = groups, -- make sure (moretrees) fruits don't fall on dig + after_place_node = function(pos, placer) -- make sure (moretrees and plumtree) fruits aren't placed by player + if placer:is_player() and node == "plumtree:plum" then + minetest.set_node(pos, {name = node, param2 = 0}) + elseif placer:is_player() then + minetest.set_node(pos, {name = node, param2 = 1}) + end + end, + on_dig = minetest.node_dig, -- override on_dig functions causing regrowth not to work + after_dig_node = function(pos, oldnode, oldmetadata, digger) + if oldnode.param2 == 0 and oldnode.name ~= "plumtree:plum" + or oldnode.name == "plumtree:plum" and oldnode.param2 == 1 + or oldnode.name == "cacaotree:pod" then + minetest.set_node(pos, {name = "regrowing_fruits:"..fruit.."_mark", param2 = oldnode.param2}) + minetest.get_node_timer(pos):start(math.random(300, 1500)) + end + end, + }) + end) -- air node to mark fruit pos minetest.register_node("regrowing_fruits:"..fruit.."_mark", {