canapa_ice.lua 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. -- get Boilerplate for Translations
  2. local S = cannabis.S
  3. local path = cannabis.path
  4. minetest.register_node("cannabis:canapa_ice", {
  5. description = S("Hemp ice"),
  6. drawtype = "plantlike",
  7. tiles = {"cannabis_canapa_ice.png"},
  8. inventory_image = "cannabis_canapa_ice.png",
  9. wield_image = "cannabis_canapa_ice.png",
  10. paramtype = "light",
  11. sunlight_propagates = true,
  12. walkable = false,
  13. selection_box = {
  14. type = "fixed",
  15. fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
  16. },
  17. groups = {snappy = 3, flammable = 2},
  18. sounds ={"cannabis_canapa_s"},
  19. drop = {
  20. max_items = 3,
  21. items = {
  22. {items = {"cannabis:canapa_ice"}, rarity = 1 },
  23. {items = {"cannabis:canapa_ice_leaves"}, rarity = 1 },
  24. --{items = {"cannabis:canapa_ice_seed"}, rarity = 1 },
  25. }
  26. },
  27. after_dig_node = function(pos, node, metadata, digger)
  28. cannabis.dig_up_ice(pos, node, digger)
  29. end,
  30. })
  31. --____________________________________
  32. if minetest.get_modpath("farming") then
  33. function minetest.grow_canapa_ice(pos, node)
  34. pos.y = pos.y - 1
  35. local name = minetest.get_node(pos).name
  36. if name ~= "farming:soil_wet"
  37. then
  38. return
  39. end
  40. if not minetest.find_node_near(pos, 5, {"default:water"}) then
  41. return
  42. end
  43. pos.y = pos.y + 1
  44. local height = 0
  45. while node.name == "cannabis:canapa_ice" and height < 6 do
  46. height = height + 1
  47. pos.y = pos.y + 1
  48. node = minetest.get_node(pos)
  49. end
  50. if height==6 then
  51. minetest.set_node(pos, {name = "cannabis:flowering_ice"})
  52. else
  53. if height == 6 or node.name ~= "air" then
  54. return
  55. end
  56. minetest.set_node(pos, {name = "cannabis:canapa_ice"})
  57. return true
  58. end
  59. end
  60. end
  61. --___________________________________
  62. --function
  63. -- Dig upwards function for dig_up 2 elements
  64. --
  65. function cannabis.dig_up_ice(pos, node, digger)
  66. if digger == nil then return end
  67. local np = {x = pos.x, y = pos.y + 1, z = pos.z}
  68. local nn = minetest.get_node(np)
  69. if nn.name == node.name or nn.name == "cannabis:flowering_ice" then
  70. minetest.node_dig(np, nn, digger)
  71. end
  72. end
  73. --____________________________________
  74. function minetest.grow_canapa_ice(pos, node)
  75. pos.y = pos.y - 1
  76. local name = minetest.get_node(pos).name
  77. if name ~= "default:sand"
  78. and name ~= "farming:soil_wet"
  79. --and name ~= "farming:soil"
  80. and name ~= "default:silver_sand"
  81. and name ~= "default:dirt_with_snow"
  82. and name ~= "default:permafrost_with_moss"
  83. and name ~= "default:dirt"
  84. and name ~= "default:dirt_with_coniferous_litter" then
  85. return
  86. end
  87. if not minetest.find_node_near(pos, 5, {"default:snow"}) then
  88. return
  89. end
  90. --[[if minetest.get_modpath("farming") then
  91. local name=minetest.get_node(pos).name
  92. if name ~= "farming:soil_wet" then
  93. return
  94. end
  95. end
  96. if minetest.get_modpath("farming") then
  97. if not minetest.find_node_near(pos, 5, {"default:water"}) then
  98. return
  99. end
  100. end]]
  101. pos.y = pos.y + 1
  102. local height = 0
  103. while node.name == "cannabis:canapa_ice" and height < 6 do
  104. height = height + 1
  105. pos.y = pos.y + 1
  106. node = minetest.get_node(pos)
  107. end
  108. if height==6 then
  109. minetest.set_node(pos, {name = "cannabis:flowering_ice"})
  110. else
  111. if height == 6 or node.name ~= "air" then
  112. return
  113. end
  114. minetest.set_node(pos, {name = "cannabis:canapa_ice"})
  115. return true
  116. end
  117. end
  118. --mapgen
  119. minetest.register_abm({
  120. label = "Grow canapa ice",
  121. nodenames = {"cannabis:canapa_ice"},
  122. neighbors ={ "default:silver_sand",
  123. "default:dirt",
  124. "default:sand",
  125. "default:dirt_with_snow",
  126. "default:dirt_with_coniferous_litter",
  127. "default:permafrost_with_moss",},
  128. interval = 2,
  129. chance = 10,
  130. action = function(...)
  131. minetest.grow_canapa_ice(...)
  132. end
  133. })
  134. --___________________________________________________________
  135. if minetest.get_modpath("default") then
  136. minetest.register_decoration({
  137. deco_type = "simple",
  138. place_on = {"default:silver_sand",
  139. "default:dirt",
  140. "default:sand",
  141. "default:dirt_with_snow",
  142. "default:dirt_with_coniferous_litter",
  143. "default:permafrost_with_moss",
  144. },
  145. sidelen = 16,
  146. noise_params = {
  147. offset = -0.3,
  148. scale = 0.7,
  149. spread = {x = 100, y =100, z =100},
  150. seed = 354,
  151. octaves = 1,
  152. persist = 1
  153. },
  154. biomes = {
  155. "taiga",
  156. "coniferous_forest",
  157. "tundra",
  158. "snowy_grassland",
  159. "cold_desert",
  160. "tundra_beach",
  161. "delicious_forest_shore",
  162. "floatland_coniferous_forest"},
  163. y_min = 6,
  164. y_max = 31000,
  165. decoration = "cannabis:canapa_ice",
  166. height = 2,
  167. height_max = 7,
  168. spawn_by ="default:snow",
  169. num_spawn_by = 1,
  170. })
  171. end
  172. minetest.register_node('cannabis:seedling_i', {
  173. description = S("Hemp ice(seedling)"),
  174. drawtype = 'plantlike',
  175. waving = 1,
  176. tiles = { '1hemp_seedling_ice.png' },
  177. inventory_image = '1hemp_seedling_ice.png',
  178. wield_image = '1hemp_seedling_ice.png',
  179. sunlight_propagates = true,
  180. paramtype = 'light',
  181. walkable = false,
  182. groups = { snappy = 3, poisonivy=1, flora_block=1 },
  183. sounds ={"cannabis_canapa_s3"},
  184. buildable_to = true,
  185. })
  186. minetest.register_node('cannabis:sproutling_i', {
  187. description = S("Hemp ice (sproutling)"),
  188. drawtype = 'plantlike',
  189. waving = 1,
  190. tiles = { 'hemp_sproutling_ice.png' },
  191. inventory_image = 'hemp_sproutling_ice.png',
  192. wield_image = 'hemp_sproutling_ice.png',
  193. sunlight_propagates = true,
  194. paramtype = 'light',
  195. walkable = false,
  196. groups = { snappy = 3, poisonivy=1, flora_block=1 },
  197. sounds ={"cannabis_canapa_s3"},
  198. buildable_to = true,
  199. })
  200. minetest.register_node('cannabis:climbing_i', {
  201. description = S("Hemp ice (climbing plant)"),
  202. drawtype = 'signlike',
  203. tiles = { 'hemp_climbing_ice.png' },
  204. inventory_image = 'hemp_climbing_ice.png',
  205. wield_image = 'hemp_climbing_ice.png',
  206. sunlight_propagates = true,
  207. paramtype = 'light',
  208. paramtype2 = 'wallmounted',
  209. walkable = false,
  210. groups = { snappy = 3, poisonivy=1, flora_block=1 },
  211. sounds ={"cannabis_canapa_s3"},
  212. selection_box = {
  213. type = "wallmounted",
  214. --wall_side = = <default>
  215. },
  216. buildable_to = true,
  217. })
  218. minetest.register_node('cannabis:flowering_ice', {
  219. description = S("Hemp (Ice flowering)"),
  220. drawtype = 'plantlike',
  221. waving = 1,
  222. tiles = { 'cannabis_canapa_ice_flower.png' },
  223. sunlight_propagates = true,
  224. paramtype = 'light',
  225. walkable = false,
  226. selection_box = {
  227. type = "fixed",
  228. fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
  229. },
  230. groups = { snappy = 3, poisonivy=1, flora_block=1 },
  231. sounds ={"cannabis_canapa_s3"},
  232. buildable_to = true,
  233. drop = {
  234. max_items = 3,
  235. items = {
  236. {items = {"cannabis:canapa_ice_flower"}, rarity = 1 },
  237. {items = {"cannabis:canapa_ice_seed"}, rarity = 1 },
  238. }}
  239. })