corn.lua 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. minetest.register_craftitem("lottfarming:corn_seed", {
  2. description = "Corn Seeds",
  3. inventory_image = "lottfarming_corn_seed.png",
  4. on_place = function(itemstack, placer, pointed_thing)
  5. return place_seed(itemstack, placer, pointed_thing, "lottfarming:corn_1", 3)
  6. end,
  7. })
  8. minetest.register_craftitem("lottfarming:corn", {
  9. description = "Corn",
  10. inventory_image = "lottfarming_corn.png",
  11. groups = {salad=1},
  12. on_use = minetest.item_eat(4),
  13. })
  14. minetest.register_node("lottfarming:corn_1", {
  15. paramtype = "light",
  16. paramtype2 = "meshoptions",
  17. walkable = false,
  18. drawtype = "plantlike",
  19. drop = "",
  20. tiles = {"lottfarming_corn_1.png"},
  21. waving = 1,
  22. selection_box = {
  23. type = "fixed",
  24. fixed = {
  25. {-0.5, -0.5, -0.5, 0.5, -0.5+3/16, 0.5}
  26. },
  27. },
  28. groups = {snappy=3, flammable=2, not_in_creative_inventory=1, plant=1},
  29. sounds = default.node_sound_leaves_defaults(),
  30. })
  31. minetest.register_node("lottfarming:corn_2", {
  32. paramtype = "light",
  33. paramtype2 = "meshoptions",
  34. walkable = false,
  35. drawtype = "plantlike",
  36. drop = "",
  37. tiles = {"lottfarming_corn_2.png"},
  38. waving = 1,
  39. selection_box = {
  40. type = "fixed",
  41. fixed = {
  42. {-0.5, -0.5, -0.5, 0.5, -0.5+3/16, 0.5}
  43. },
  44. },
  45. groups = {snappy=3, flammable=2, not_in_creative_inventory=1, plant=1},
  46. sounds = default.node_sound_leaves_defaults(),
  47. })
  48. minetest.register_node("lottfarming:corn_3", {
  49. paramtype = "light",
  50. paramtype2 = "meshoptions",
  51. walkable = false,
  52. drawtype = "plantlike",
  53. drop = "",
  54. tiles = {"lottfarming_corn_3.png"},
  55. waving = 1,
  56. groups = {snappy=3, flammable=2, not_in_creative_inventory=1, plant=1},
  57. sounds = default.node_sound_leaves_defaults(),
  58. })
  59. minetest.register_node("lottfarming:corn_4", {
  60. paramtype = "light",
  61. paramtype2 = "meshoptions",
  62. walkable = false,
  63. drawtype = "plantlike",
  64. drop = "",
  65. tiles = {"lottfarming_corn_4.png"},
  66. waving = 1,
  67. groups = {snappy=3, flammable=2, not_in_creative_inventory=1, plant=1},
  68. sounds = default.node_sound_leaves_defaults(),
  69. })
  70. minetest.register_node("lottfarming:corn_21", {
  71. paramtype = "light",
  72. paramtype2 = "meshoptions",
  73. walkable = false,
  74. drawtype = "plantlike",
  75. drop = "",
  76. tiles = {"lottfarming_corn_21.png"},
  77. waving = 1,
  78. groups = {snappy=3, flammable=2, not_in_creative_inventory=1, plant=1},
  79. sounds = default.node_sound_leaves_defaults(),
  80. })
  81. minetest.register_node("lottfarming:corn_22", {
  82. paramtype = "light",
  83. paramtype2 = "meshoptions",
  84. walkable = false,
  85. drawtype = "plantlike",
  86. drop = "",
  87. tiles = {"lottfarming_corn_22.png"},
  88. waving = 1,
  89. groups = {snappy=3, flammable=2, not_in_creative_inventory=1, plant=1},
  90. sounds = default.node_sound_leaves_defaults(),
  91. })
  92. minetest.register_node("lottfarming:corn_23", {
  93. paramtype = "light",
  94. paramtype2 = "meshoptions",
  95. walkable = false,
  96. drawtype = "plantlike",
  97. drop = "",
  98. tiles = {"lottfarming_corn_23.png"},
  99. waving = 1,
  100. drop = {
  101. max_items = 6,
  102. items = {
  103. { items = {'lottfarming:corn'} },
  104. { items = {'lottfarming:corn'}, rarity = 2},
  105. { items = {'lottfarming:corn'}, rarity = 5},
  106. { items = {'lottfarming:corn_seed'} },
  107. { items = {'lottfarming:corn_seed'}, rarity = 2 },
  108. { items = {'lottfarming:corn_seed'}, rarity = 5 }
  109. }
  110. },
  111. groups = {snappy=3, flammable=2, not_in_creative_inventory=1, plant=1},
  112. sounds = default.node_sound_leaves_defaults(),
  113. })
  114. minetest.register_node("lottfarming:corn_31", {
  115. paramtype = "light",
  116. paramtype2 = "meshoptions",
  117. walkable = false,
  118. drawtype = "plantlike",
  119. drop = "",
  120. tiles = {"lottfarming_corn_31.png"},
  121. waving = 1,
  122. groups = {snappy=3, flammable=2, not_in_creative_inventory=1, plant=1},
  123. sounds = default.node_sound_leaves_defaults(),
  124. })
  125. minetest.register_node("lottfarming:corn_32", {
  126. paramtype = "light",
  127. paramtype2 = "meshoptions",
  128. walkable = false,
  129. drawtype = "plantlike",
  130. drop = "",
  131. tiles = {"lottfarming_corn_32.png"},
  132. waving = 1,
  133. drop = {
  134. max_items = 6,
  135. items = {
  136. { items = {'lottfarming:corn'} },
  137. { items = {'lottfarming:corn'}, rarity = 2},
  138. { items = {'lottfarming:corn'}, rarity = 5},
  139. { items = {'lottfarming:corn_seed'} },
  140. { items = {'lottfarming:corn_seed'}, rarity = 2 },
  141. { items = {'lottfarming:corn_seed'}, rarity = 5 }
  142. }
  143. },
  144. groups = {snappy=3, flammable=2, not_in_creative_inventory=1, plant=1},
  145. sounds = default.node_sound_leaves_defaults(),
  146. })
  147. chance = 20
  148. interval = 45
  149. whereon = "farming:soil_wet"
  150. wherein = "air"
  151. minetest.register_abm({
  152. nodenames = "lottfarming:corn_1",
  153. interval = interval,
  154. chance = chance,
  155. action = function(pos, node)
  156. pos.y = pos.y-1
  157. if minetest.get_node(pos).name ~= "farming:soil_wet" then
  158. return
  159. end
  160. pos.y = pos.y+1
  161. local light_level = minetest.get_node_light(pos)
  162. if not light_level then
  163. return
  164. end
  165. local c = math.ceil(2 * (light_level - 13) ^ 2 + 1)
  166. if light_level > 7 and (math.random(1, c) == 1 or light_level >= 13) then
  167. pos.y=pos.y+1
  168. if minetest.get_node(pos).name ~= wherein then
  169. return
  170. end
  171. pos.y=pos.y-1
  172. minetest.set_node(pos, {name='lottfarming:corn_2', param2 = 3})
  173. end
  174. end
  175. })
  176. minetest.register_abm({
  177. nodenames = "lottfarming:corn_2",
  178. interval = interval,
  179. chance = chance,
  180. action = function(pos, node)
  181. pos.y = pos.y-1
  182. if minetest.get_node(pos).name ~= "farming:soil_wet" then
  183. return
  184. end
  185. pos.y = pos.y+1
  186. local light_level = minetest.get_node_light(pos)
  187. if not light_level then
  188. return
  189. end
  190. local c = math.ceil(2 * (light_level - 13) ^ 2 + 1)
  191. if light_level > 7 and (math.random(1, c) == 1 or light_level >= 13) then
  192. pos.y=pos.y+1
  193. minetest.set_node(pos, {name='lottfarming:corn_21', param2 = 3})
  194. pos.y=pos.y-1
  195. minetest.set_node(pos, {name='lottfarming:corn_3', param2 = 3})
  196. end
  197. end
  198. })
  199. minetest.register_abm({
  200. nodenames = "lottfarming:corn_3",
  201. interval = interval,
  202. chance = chance,
  203. action = function(pos, node)
  204. pos.y = pos.y-1
  205. if minetest.get_node(pos).name ~= "farming:soil_wet" then
  206. return
  207. end
  208. pos.y = pos.y+1
  209. local light_level = minetest.get_node_light(pos)
  210. if not light_level then
  211. return
  212. end
  213. local c = math.ceil(2 * (light_level - 13) ^ 2 + 1)
  214. if light_level > 7 and (math.random(1, c) == 1 or light_level >= 13) then
  215. pos.y=pos.y+1
  216. pos.y=pos.y+1
  217. minetest.set_node(pos, {name='lottfarming:corn_31', param2 = 3})
  218. pos.y=pos.y-1
  219. minetest.set_node(pos, {name='lottfarming:corn_22', param2 = 3})
  220. pos.y=pos.y-1
  221. minetest.set_node(pos, {name='lottfarming:corn_4', param2 = 3})
  222. end
  223. end
  224. })
  225. minetest.register_abm({
  226. nodenames = "lottfarming:corn_22",
  227. interval = interval,
  228. chance = chance,
  229. action = function(pos, node)
  230. local light_level = minetest.get_node_light(pos)
  231. if not light_level then
  232. return
  233. end
  234. local c = math.ceil(2 * (light_level - 13) ^ 2 + 1)
  235. if light_level > 7 and (math.random(1, c) == 1 or light_level >= 13) then
  236. pos.y=pos.y+1
  237. minetest.set_node(pos, {name='lottfarming:corn_32', param2 = 3})
  238. pos.y=pos.y-1
  239. minetest.set_node(pos, {name='lottfarming:corn_23', param2 = 3})
  240. end
  241. end
  242. })