insects.lua 1.2 KB

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