functions.lua 889 B

1234567891011121314151617181920212223242526272829303132333435
  1. --
  2. -- Turn seedling to flower
  3. --
  4. minetest.register_abm({
  5. nodenames = {"nodetest:seedling"},
  6. interval = 11,
  7. chance = 20,
  8. catch_up = false,
  9. action = function(pos, node)
  10. local above = {x=pos.x, y=pos.y+1, z=pos.z}
  11. local name = minetest.get_node(above).name
  12. if (minetest.get_node_light(above) or 0) >= 11 then
  13. local flower_choice = math.random(1, 7)
  14. local flower
  15. if flower_choice == 1 then
  16. flower = "flowers:tulip"
  17. elseif flower_choice == 2 then
  18. flower = "flowers:rose"
  19. elseif flower_choice == 3 then
  20. flower = "flowers:viola"
  21. elseif flower_choice == 4 then
  22. flower = "flowers:geranium"
  23. elseif flower_choice == 5 then
  24. flower = "flowers:dandelion_white"
  25. elseif flower_choice == 6 then
  26. flower = "flowers:dandelion_yellow"
  27. elseif flower_choice == 7 then
  28. flower = "air"
  29. end
  30. minetest.set_node(pos, {name=flower})
  31. end
  32. end
  33. })