vines.lua 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. local base_speed = 100
  2. minetest.register_craftitem("farming_super:kiwi", {
  3. description = "Kiwi",
  4. inventory_image = "farming_super_kiwi.png",
  5. on_use = minetest.item_eat(2),
  6. groups = {flammable = 2},
  7. })
  8. minetest.register_craftitem("farming_super:kiwi_sapling", {
  9. description = "Kiwi Sapling",
  10. inventory_image = "farming_super_kiwi_vine.png",
  11. groups = {flammable = 2},
  12. on_place = function(itemstack, placer, pointed_thing)
  13. local n = minetest.get_node(pointed_thing.under)
  14. if n.name == "farming:soil_wet" then
  15. itemstack:take_item()
  16. minetest.set_node(pointed_thing.under, {name = "farming_super:kiwi_vine", param2 = 1,})
  17. end
  18. return itemstack
  19. end,
  20. })
  21. minetest.register_node("farming_super:kiwi_2", {
  22. description = "Kiwi Plant",
  23. drawtype = "plantlike",
  24. waving = 1,
  25. visual_scale = 1.69,
  26. tiles = {"farming_super_kiwi_vine_1.png"},
  27. wield_image = "farming_super_kiwi_vine_1.png",
  28. paramtype = "light",
  29. paramtype2 = "meshoptions",
  30. sunlight_propagates = true,
  31. walkable = false,
  32. buildable_to = true,
  33. groups = {snappy = 3, flora = 1, flammable = 1},
  34. sounds = default.node_sound_leaves_defaults(),
  35. selection_box = {
  36. type = "fixed",
  37. fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, 0.5, 6 / 16},
  38. },
  39. place_param2 = 2,
  40. })
  41. minetest.register_node("farming_super:kiwi_3", {
  42. description = "Kiwi Plant",
  43. drawtype = "plantlike",
  44. waving = 1,
  45. visual_scale = 1.2,
  46. tiles = {"farming_super_kiwi_vine_1.png"},
  47. wield_image = "farming_super_kiwi_vine_1.png",
  48. paramtype = "light",
  49. paramtype2 = "meshoptions",
  50. sunlight_propagates = true,
  51. walkable = false,
  52. buildable_to = true,
  53. groups = {snappy = 3, flora = 1, flammable = 1},
  54. sounds = default.node_sound_leaves_defaults(),
  55. selection_box = {
  56. type = "fixed",
  57. fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, 0.5, 6 / 16},
  58. },
  59. place_param2 = 2,
  60. })
  61. minetest.register_node("farming_super:kiwi_2_fruit", {
  62. description = "Ripe Kiwi Plant",
  63. drawtype = "plantlike",
  64. waving = 1,
  65. visual_scale = 1.69,
  66. tiles = {"farming_super_kiwi_vine_with_fruit.png"},
  67. wield_image = "farming_super_kiwi_vine_with_fruit.png",
  68. paramtype = "light",
  69. paramtype2 = "meshoptions",
  70. sunlight_propagates = true,
  71. walkable = false,
  72. buildable_to = true,
  73. groups = {snappy = 3, flora = 1, flammable = 1},
  74. sounds = default.node_sound_leaves_defaults(),
  75. selection_box = {
  76. type = "fixed",
  77. fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, 0.5, 6 / 16},
  78. },
  79. drop = {
  80. max_items = 2,
  81. items = {
  82. {items = {"farming_super:kiwi_sapling"}, rarity = 10},
  83. {items = {"farming_super:kiwi 2"}},
  84. {items = {"farming_super:kiwi 3"}},
  85. },
  86. },
  87. place_param2 = 2,
  88. after_destruct = function(pos)
  89. minetest.set_node(pos, {name = "farming_super:kiwi_2"})
  90. end,
  91. })
  92. minetest.register_node("farming_super:kiwi_3_fruit", {
  93. description = "Ripe Kiwi Plant",
  94. drawtype = "plantlike",
  95. waving = 1,
  96. visual_scale = 1.2,
  97. tiles = {"farming_super_kiwi_vine_with_fruit.png"},
  98. wield_image = "farming_super_kiwi_vine_with_fruit.png",
  99. paramtype = "light",
  100. paramtype2 = "meshoptions",
  101. sunlight_propagates = true,
  102. walkable = false,
  103. buildable_to = true,
  104. groups = {snappy = 3, flora = 1, flammable = 1},
  105. sounds = default.node_sound_leaves_defaults(),
  106. selection_box = {
  107. type = "fixed",
  108. fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, 0.5, 6 / 16},
  109. },
  110. drop = {
  111. max_items = 2,
  112. items = {
  113. {items = {"farming_super:kiwi_sapling"}, rarity = 10},
  114. {items = {"farming_super:kiwi 2"}},
  115. {items = {"farming_super:kiwi 3"}},
  116. },
  117. },
  118. place_param2 = 2,
  119. after_destruct = function(pos)
  120. minetest.set_node(pos, {name = "farming_super:kiwi_3"})
  121. end,
  122. })
  123. minetest.register_node("farming_super:kiwi_vine", {
  124. description = "Kiwi Plant",
  125. drawtype = "plantlike_rooted",
  126. waving = 1,
  127. tiles = {"default_sand.png"},
  128. tiles = {"default_dirt.png^farming_soil_wet.png", "default_dirt.png^farming_soil_wet_side.png"},
  129. drop = "default:dirt",
  130. special_tiles = {{name = "farming_super_kiwi_vine.png", tileable_vertical = true}},
  131. inventory_image = "farming_super_kiwi_vine.png",
  132. paramtype = "light",
  133. paramtype2 = "leveled",
  134. place_param2 = 1,
  135. groups = {snappy = 3},
  136. selection_box = {
  137. type = "fixed",
  138. fixed = {
  139. {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
  140. {-2/16, 0.5, -2/16, 2/16, 3.5, 2/16},
  141. },
  142. },
  143. node_dig_prediction = "default:sand",
  144. node_placement_prediction = "",
  145. sounds = default.node_sound_sand_defaults({
  146. dig = {name = "default_dig_snappy", gain = 0.2},
  147. dug = {name = "default_grass_footstep", gain = 0.25},
  148. }),
  149. after_destruct = function(pos, oldnode)
  150. local n = minetest.get_node(pos)
  151. if n.name ~= "farming_super:kiwi_vine" then
  152. minetest.set_node(pos, {name = "farming:soil_wet"})
  153. end
  154. end
  155. })
  156. minetest.register_abm({
  157. label = "Kiwi wire",
  158. neighbors = {"farming_super:kiwi_2"},
  159. nodenames = {"farming_super:wire"},
  160. interval = 1,
  161. chance = 1,
  162. action = function(pos, node)
  163. local airs = minetest.find_nodes_in_area(
  164. {x=pos.x-1, y=pos.y-1, z=pos.z-1},
  165. {x=pos.x+1, y=pos.y-1, z=pos.z+1},
  166. {"air"})
  167. if #airs > 0 then
  168. local p = airs[math.random(1,#airs)]
  169. minetest.set_node(p, {name="farming_super:kiwi_3", param2 = 2,})
  170. end
  171. end,
  172. })
  173. minetest.register_abm({
  174. label = "Kiwi Vine Growth",
  175. nodenames = {"farming_super:kiwi_vine"},
  176. interval = 1,
  177. chance = 1,
  178. action = function(pos, node)
  179. local lvl = minetest.get_node_level(pos)
  180. local cnt = math.max(1, math.ceil(((lvl - 7) / 16) ))
  181. local top = {x=pos.x, y=pos.y + cnt, z=pos.z}
  182. local stick = minetest.get_node(top)
  183. if stick.name == "farming_super:pole" then
  184. minetest.add_node_level(pos, 1)
  185. elseif stick.name == "farming_super:wire" then
  186. local airs = minetest.find_nodes_in_area(
  187. {x=top.x-1, y=top.y-1, z=top.z-1},
  188. {x=top.x+1, y=top.y-1, z=top.z+1},
  189. {"air"})
  190. if #airs > 0 then
  191. local p = airs[math.random(1,#airs)]
  192. minetest.set_node(p, {name="farming_super:kiwi_2", param2 = 2})
  193. end
  194. end
  195. -- local n = minetest.get_node(pos)
  196. -- print(n.param2)
  197. -- minetest.set_node(pos, {name = "farming_super:kiwi_1", param2 = node.param2 + 1})
  198. end,
  199. })
  200. minetest.register_abm({
  201. label = "Kiwi Vine Fruit",
  202. nodenames = {"farming_super:kiwi_2"},
  203. interval = 1,
  204. chance = 5,
  205. action = function(pos, node)
  206. minetest.set_node(pos, {name = "farming_super:kiwi_2_fruit", param2 = 2})
  207. end,
  208. })
  209. minetest.register_abm({
  210. label = "Kiwi Vine Fruit",
  211. nodenames = {"farming_super:kiwi_3"},
  212. interval = 1,
  213. chance = 5,
  214. action = function(pos, node)
  215. minetest.set_node(pos, {name = "farming_super:kiwi_3_fruit", param2 = 2})
  216. end,
  217. })