canapa_red.lua 6.9 KB

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