red.lua 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. minetest.register_craftitem("lottfarming:red_mushroom_spore", {
  2. description = "Red Mushroom Spores",
  3. inventory_image = "lottfarming_red_mushroom_spore.png",
  4. on_place = function(itemstack, placer, pointed_thing)
  5. return place_spore(itemstack, placer, pointed_thing, "lottfarming:red_mushroom_1", 9)
  6. end,
  7. })
  8. minetest.register_node("lottfarming:red_mushroom", {
  9. description = "Red Mushroom",
  10. paramtype = "light",
  11. paramtype2 = "meshoptions",
  12. place_param2 = 9,
  13. walkable = false,
  14. drawtype = "plantlike",
  15. drop = "",
  16. tiles = {"lottfarming_red_mushroom_4.png"},
  17. selection_box = {
  18. type = "fixed",
  19. fixed = {
  20. {-0.5, -0.5, -0.5, 0.5, -0.5+3/16, 0.5}
  21. },
  22. },
  23. groups = {snappy=3, flammable=2, mushroom=1, flower=1, color_red=1},
  24. sounds = default.node_sound_leaves_defaults(),
  25. inventory_image = "lottfarming_red_mushroom.png",
  26. on_use = minetest.item_eat(2),
  27. })
  28. minetest.register_node("lottfarming:red_mushroom_1", {
  29. paramtype = "light",
  30. paramtype2 = "meshoptions",
  31. walkable = false,
  32. drawtype = "plantlike",
  33. drop = "",
  34. tiles = {"lottfarming_red_mushroom_1.png"},
  35. waving = 1,
  36. selection_box = {
  37. type = "fixed",
  38. fixed = {
  39. {-0.5, -0.5, -0.5, 0.5, -0.5+3/16, 0.5}
  40. },
  41. },
  42. groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
  43. sounds = default.node_sound_leaves_defaults(),
  44. })
  45. minetest.register_node("lottfarming:red_mushroom_2", {
  46. paramtype = "light",
  47. paramtype2 = "meshoptions",
  48. walkable = false,
  49. drawtype = "plantlike",
  50. drop = "",
  51. tiles = {"lottfarming_red_mushroom_2.png"},
  52. waving = 1,
  53. selection_box = {
  54. type = "fixed",
  55. fixed = {
  56. {-0.5, -0.5, -0.5, 0.5, -0.5+3/16, 0.5}
  57. },
  58. },
  59. groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
  60. sounds = default.node_sound_leaves_defaults(),
  61. })
  62. minetest.register_node("lottfarming:red_mushroom_3", {
  63. paramtype = "light",
  64. paramtype2 = "meshoptions",
  65. walkable = false,
  66. drawtype = "plantlike",
  67. drop = "",
  68. tiles = {"lottfarming_red_mushroom_3.png"},
  69. waving = 1,
  70. selection_box = {
  71. type = "fixed",
  72. fixed = {
  73. {-0.5, -0.5, -0.5, 0.5, -0.5+3/16, 0.5}
  74. },
  75. },
  76. groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
  77. sounds = default.node_sound_leaves_defaults(),
  78. })
  79. minetest.register_node("lottfarming:red_mushroom_4", {
  80. paramtype = "light",
  81. paramtype2 = "meshoptions",
  82. walkable = false,
  83. drawtype = "plantlike",
  84. drop = "",
  85. tiles = {"lottfarming_red_mushroom_4.png"},
  86. waving = 1,
  87. after_dig_node = function(pos)
  88. end,
  89. drop = {
  90. max_items = 6,
  91. items = {
  92. { items = {'lottfarming:red_mushroom'} },
  93. { items = {'lottfarming:red_mushroom'}, rarity = 2},
  94. { items = {'lottfarming:red_mushroom'}, rarity = 5},
  95. { items = {'lottfarming:red_mushroom_spore'} },
  96. { items = {'lottfarming:red_mushroom_spore'}, rarity = 2},
  97. { items = {'lottfarming:red_mushroom_spore'}, rarity = 5},
  98. }
  99. },
  100. groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
  101. sounds = default.node_sound_leaves_defaults(),
  102. })
  103. chance = 10
  104. interval = 30
  105. whereon = "lottfarming:decay_tree"
  106. wherein = "air"
  107. minetest.register_abm({
  108. nodenames = "lottfarming:red_mushroom_1",
  109. interval = interval,
  110. chance = chance,
  111. action = function(pos, node)
  112. pos.y = pos.y-1
  113. if minetest.get_node(pos).name ~= "lottfarming:decay_tree" then
  114. return
  115. end
  116. pos.y = pos.y+1
  117. if not minetest.get_node_light(pos) then
  118. return
  119. end
  120. if minetest.get_node_light(pos) > 8 then
  121. return
  122. end
  123. minetest.set_node(pos, {name='lottfarming:red_mushroom_2', param2 = 9})
  124. end
  125. })
  126. minetest.register_abm({
  127. nodenames = "lottfarming:red_mushroom_2",
  128. interval = 30,
  129. chance = 10,
  130. action = function(pos, node)
  131. pos.y = pos.y-1
  132. if minetest.get_node(pos).name ~= "lottfarming:decay_tree" then
  133. return
  134. end
  135. pos.y = pos.y+1
  136. if not minetest.get_node_light(pos) then
  137. return
  138. end
  139. if minetest.get_node_light(pos) > 8 then
  140. return
  141. end
  142. minetest.set_node(pos, {name='lottfarming:red_mushroom_3', param2 = 9})
  143. end
  144. })
  145. minetest.register_abm({
  146. nodenames = "lottfarming:red_mushroom_3",
  147. interval = interval,
  148. chance = chance,
  149. action = function(pos, node)
  150. pos.y = pos.y-1
  151. if minetest.get_node(pos).name ~= "lottfarming:decay_tree"
  152. and minetest.get_node(pos).name ~= "default:tree" then
  153. return
  154. end
  155. pos.y = pos.y+1
  156. if not minetest.get_node_light(pos) then
  157. return
  158. end
  159. if minetest.get_node_light(pos) > 8 then
  160. return
  161. end
  162. minetest.set_node(pos, {name='lottfarming:red_mushroom_4', param2 = 9})
  163. end
  164. })
  165. num = PseudoRandom(111)
  166. minetest.register_abm({
  167. nodenames = "lottfarming:red_mushroom_3",
  168. interval = 30,
  169. chance = 10,
  170. action = function(pos, node)
  171. pos.x = pos.x + num:next(-1, 1)
  172. pos.z = pos.z + num:next(-1, 1)
  173. if minetest.get_node(pos).name=="air" then
  174. pos.y = pos.y-1
  175. name = minetest.get_node(pos).name
  176. if name=="default:tree" then
  177. pos.y=pos.y+1
  178. minetest.set_node(pos, {name='lottfarming:red_mushroom_3', param2 = 9})
  179. end
  180. if name=="air" then
  181. pos.y=pos.y-1
  182. name = minetest.get_node(pos).name
  183. if name=="default:tree" then
  184. pos.y=pos.y+1
  185. minetest.set_node(pos, {name='lottfarming:red_mushroom_3', param2 = 9})
  186. end
  187. end
  188. end
  189. pos.y=pos.y+1
  190. if minetest.get_node(pos).name=="air" then
  191. pos.y = pos.y-1
  192. name = minetest.get_node(pos).name
  193. if name=="default:tree" then
  194. pos.y=pos.y+1
  195. minetest.set_node(pos, {name='lottfarming:red_mushroom_3', param2 = 9})
  196. end
  197. end
  198. end
  199. })