init.lua 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. -- Add everything:
  2. local modname = "cactus_flowers"
  3. local modpath = minetest.get_modpath(modname)
  4. minetest.register_node(modname..":pink", {
  5. description = "Pink Cactus Flower",
  6. drawtype = "plantlike",
  7. visual_scale = 0.80,
  8. tiles = {modname.."_pink.png"},
  9. inventory_image = modname.."_pink.png",
  10. wield_image = modname.."_pink.png",
  11. paramtype = "light",
  12. sunlight_propagates = true,
  13. walkable = false,
  14. buildable_to = true,
  15. groups = {snappy = 3, flammable = 2, attached_node = 1},
  16. sounds = default.node_sound_leaves_defaults(),
  17. selection_box = {
  18. type = "fixed",
  19. fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
  20. },
  21. })
  22. minetest.register_node(modname..":red", {
  23. description = "Red Cactus Flower",
  24. drawtype = "plantlike",
  25. visual_scale = 0.80,
  26. tiles = {modname.."_red.png"},
  27. inventory_image = modname.."_red.png",
  28. wield_image = modname.."_red.png",
  29. paramtype = "light",
  30. sunlight_propagates = true,
  31. walkable = false,
  32. buildable_to = true,
  33. groups = {snappy = 3, flammable = 2, attached_node = 1, bird_nest = 1},
  34. sounds = default.node_sound_leaves_defaults(),
  35. selection_box = {
  36. type = "fixed",
  37. fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
  38. },
  39. })
  40. local growaction = function(pos, node)
  41. pos.y = pos.y + 1
  42. local over = minetest.get_node(pos)
  43. if over.name ~= "air" then
  44. return
  45. end
  46. local r = math.random(1, 100)
  47. if r <= 50 then
  48. minetest.set_node(pos, {name=modname..":pink"})
  49. else
  50. minetest.set_node(pos, {name=modname..":red"})
  51. end
  52. end
  53. minetest.register_abm({
  54. nodenames = {"default:cactus"},
  55. interval = 120,
  56. chance = 10,
  57. catch_up = true,
  58. action = growaction,
  59. })