init.lua 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. -- Minetest 0.4 mod: default
  2. -- See README.txt for licensing and other information.
  3. -- Map Generation
  4. dofile(minetest.get_modpath("flowers").."/mapgen.lua")
  5. -- Aliases for original flowers mod
  6. minetest.register_alias("flowers:flower_dandelion_white", "flowers:dandelion_white")
  7. minetest.register_alias("flowers:flower_dandelion_yellow", "flowers:dandelion_yellow")
  8. minetest.register_alias("flowers:flower_geranium", "flowers:geranium")
  9. minetest.register_alias("flowers:flower_rose", "flowers:rose")
  10. minetest.register_alias("flowers:flower_tulip", "flowers:tulip")
  11. minetest.register_alias("flowers:flower_viola", "flowers:viola")
  12. minetest.register_node("flowers:dandelion_white", {
  13. description = "White Dandelion",
  14. drawtype = "plantlike",
  15. tiles = { "flowers_dandelion_white.png" },
  16. inventory_image = "flowers_dandelion_white.png",
  17. wield_image = "flowers_dandelion_white.png",
  18. sunlight_propagates = true,
  19. paramtype = "light",
  20. walkable = false,
  21. buildable_to = true,
  22. groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_white=1},
  23. sounds = default.node_sound_leaves_defaults(),
  24. selection_box = {
  25. type = "fixed",
  26. fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
  27. },
  28. })
  29. minetest.register_node("flowers:dandelion_yellow", {
  30. description = "Yellow Dandelion",
  31. drawtype = "plantlike",
  32. tiles = { "flowers_dandelion_yellow.png" },
  33. inventory_image = "flowers_dandelion_yellow.png",
  34. wield_image = "flowers_dandelion_yellow.png",
  35. sunlight_propagates = true,
  36. paramtype = "light",
  37. walkable = false,
  38. buildable_to = true,
  39. groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_yellow=1},
  40. sounds = default.node_sound_leaves_defaults(),
  41. selection_box = {
  42. type = "fixed",
  43. fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
  44. },
  45. })
  46. minetest.register_node("flowers:geranium", {
  47. description = "Blue Geranium",
  48. drawtype = "plantlike",
  49. tiles = { "flowers_geranium.png" },
  50. inventory_image = "flowers_geranium.png",
  51. wield_image = "flowers_geranium.png",
  52. sunlight_propagates = true,
  53. paramtype = "light",
  54. walkable = false,
  55. buildable_to = true,
  56. groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_blue=1},
  57. sounds = default.node_sound_leaves_defaults(),
  58. selection_box = {
  59. type = "fixed",
  60. fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
  61. },
  62. })
  63. minetest.register_node("flowers:rose", {
  64. description = "Rose",
  65. drawtype = "plantlike",
  66. tiles = { "flowers_rose.png" },
  67. inventory_image = "flowers_rose.png",
  68. wield_image = "flowers_rose.png",
  69. sunlight_propagates = true,
  70. paramtype = "light",
  71. walkable = false,
  72. buildable_to = true,
  73. groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_red=1},
  74. sounds = default.node_sound_leaves_defaults(),
  75. selection_box = {
  76. type = "fixed",
  77. fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
  78. },
  79. })
  80. minetest.register_node("flowers:tulip", {
  81. description = "Tulip",
  82. drawtype = "plantlike",
  83. tiles = { "flowers_tulip.png" },
  84. inventory_image = "flowers_tulip.png",
  85. wield_image = "flowers_tulip.png",
  86. sunlight_propagates = true,
  87. paramtype = "light",
  88. walkable = false,
  89. buildable_to = true,
  90. groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_orange=1},
  91. sounds = default.node_sound_leaves_defaults(),
  92. selection_box = {
  93. type = "fixed",
  94. fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
  95. },
  96. })
  97. minetest.register_node("flowers:viola", {
  98. description = "Viola",
  99. drawtype = "plantlike",
  100. tiles = { "flowers_viola.png" },
  101. inventory_image = "flowers_viola.png",
  102. wield_image = "flowers_viola.png",
  103. sunlight_propagates = true,
  104. paramtype = "light",
  105. walkable = false,
  106. buildable_to = true,
  107. groups = {snappy=3,flammable=2,flower=1,flora=1,attached_node=1,color_violet=1},
  108. sounds = default.node_sound_leaves_defaults(),
  109. selection_box = {
  110. type = "fixed",
  111. fixed = { -0.15, -0.5, -0.15, 0.15, 0.2, 0.15 },
  112. },
  113. })
  114. minetest.register_abm({
  115. nodenames = {"group:flora"},
  116. neighbors = {"default:dirt_with_grass", "default:desert_sand"},
  117. interval = 50,
  118. chance = 25,
  119. action = function(pos, node)
  120. pos.y = pos.y - 1
  121. local under = minetest.get_node(pos)
  122. pos.y = pos.y + 1
  123. if under.name == "default:desert_sand" then
  124. minetest.set_node(pos, {name="default:dry_shrub"})
  125. elseif under.name ~= "default:dirt_with_grass" then
  126. return
  127. end
  128. local light = minetest.get_node_light(pos)
  129. if not light or light < 13 then
  130. return
  131. end
  132. local pos0 = {x=pos.x-4,y=pos.y-4,z=pos.z-4}
  133. local pos1 = {x=pos.x+4,y=pos.y+4,z=pos.z+4}
  134. if #minetest.find_nodes_in_area(pos0, pos1, "group:flora_block") > 0 then
  135. return
  136. end
  137. local flowers = minetest.find_nodes_in_area(pos0, pos1, "group:flora")
  138. if #flowers > 3 then
  139. return
  140. end
  141. local seedling = minetest.find_nodes_in_area(pos0, pos1, "default:dirt_with_grass")
  142. if #seedling > 0 then
  143. seedling = seedling[math.random(#seedling)]
  144. seedling.y = seedling.y + 1
  145. light = minetest.get_node_light(seedling)
  146. if not light or light < 13 then
  147. return
  148. end
  149. if minetest.get_node(seedling).name == "air" then
  150. minetest.set_node(seedling, {name=node.name})
  151. end
  152. end
  153. end,
  154. })