renew/insects.lua

37 lines
1.2 KiB
Lua

-- Renew mod for Minetest
-- Copyright © 2020 Alex Yst <https://y.st./>
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License, or (at your option) any later version.
-- This software is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- Lesser General Public License for more details.
-- You should have received a copy of the GNU Lesser General Public
-- License along with this program. If not, see
-- <https://www.gnu.org./licenses/>.
minetest.register_abm({
label = "Insect Breeding",
nodenames = {
"butterflies:hidden_butterfly_red",
"butterflies:hidden_butterfly_violet",
"butterflies:hidden_butterfly_white",
"fireflies:hidden_firefly",
},
interval = 1800,
chance = 900,
catch_up = true,
action = function(pos)
local egg = minetest.find_node_near(pos, 16, "air", false)
if egg then
minetest.set_node(egg, minetest.get_node(pos))
minetest.get_node_timer(egg):start(1)
end
end,
})