canapa.lua 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. -- get Boilerplate for Translations
  2. local S = cannabis.S
  3. local path = cannabis.path
  4. minetest.register_node("cannabis:canapa", {
  5. description = S("Hemp"),
  6. drawtype = "plantlike",
  7. tiles = {"cannabis_canapa.png"},
  8. inventory_image = "cannabis_canapa.png",
  9. wield_image = "cannabis_canapa.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"}, rarity = 1 },
  23. {items = {"cannabis:canapa_leaves"}, rarity = 1 },
  24. -- {items = {"cannabis:canapa_seed"}, rarity = 1 },
  25. }
  26. },
  27. after_dig_node = function(pos, node, metadata, digger)
  28. cannabis.dig_up(pos, node, digger)
  29. --default.dig_up(pos, node, digger)
  30. end,
  31. })
  32. --function___________________________________________
  33. -- Dig upwards function for dig_up 2 elements
  34. --
  35. function cannabis.dig_up(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" then
  40. minetest.node_dig(np, nn, digger)
  41. end
  42. end
  43. --____________________________________________________
  44. function minetest.grow_canapa(pos, node)
  45. pos.y = pos.y - 1
  46. local name = minetest.get_node(pos).name
  47. if name ~= "default:dirt_with_grass"
  48. and name ~= "default:dirt"
  49. and name ~= "farming:soil_wet"
  50. and name ~= "default:dirt_with_rainforest_litter"
  51. and name ~= "default:dry_dirt"
  52. and name ~= "default:dirt_with_snow"
  53. and name ~= "default:dirt_with_coniferous_litter"
  54. then
  55. return
  56. end
  57. if not minetest.find_node_near(pos, 3, {"group:water"}) then
  58. return
  59. end
  60. pos.y = pos.y + 1
  61. local height = 0
  62. while node.name == "cannabis:canapa" and height < 6 do
  63. height = height + 1
  64. pos.y = pos.y + 1
  65. node = minetest.get_node(pos)
  66. end
  67. if height==6 then
  68. minetest.set_node(pos, {name = "cannabis:flowering"})
  69. --minetest.swap_node(pos, {name = "grow:liva2" })
  70. else
  71. if height == 6 or node.name ~= "air" then
  72. return
  73. end
  74. minetest.set_node(pos, {name = "cannabis:canapa"})
  75. return true
  76. end
  77. end
  78. --mapgen
  79. minetest.register_abm({
  80. label = "Grow canapa",
  81. nodenames = {"cannabis:canapa"},
  82. neighbors ={"default:dirt_with_grass",
  83. "default:dirt",
  84. "default:dirt_with_rainforest_litter",
  85. "default:dry_dirt",
  86. "default:dirt_with_snow",
  87. "default:dirt_with_coniferous_litter"
  88. },
  89. interval = 2,
  90. chance = 10,
  91. action = function(...)
  92. minetest.grow_canapa(...)
  93. end
  94. })
  95. if minetest.get_modpath("default") then
  96. --[[minetest.register_biome({
  97. name = "canapa_swamp",
  98. --node_dust = "",
  99. node_top ={ "default:dirt_with_grass",
  100. "default:dirt_with_grass" ,
  101. "default:dirt" ,
  102. "default:dirt_with_rainforest_litter",
  103. "default:dry_dirt",
  104. "default:dirt_with_snow",
  105. "default:dirt_with_coniferous_litter"},
  106. depth_top = 1,
  107. node_filler = "default:dirt",
  108. depth_filler = 3,
  109. --node_stone = "",
  110. --node_water_top = "",
  111. --depth_water_top = ,
  112. --node_water = "",
  113. --node_river_water = "",
  114. node_riverbed = "default:sand",
  115. depth_riverbed = 2,
  116. y_min = 1,
  117. y_max = 2,
  118. heat_point = 89,
  119. humidity_point = 22,
  120. })]]
  121. minetest.register_decoration({
  122. deco_type = "simple",
  123. place_on = {"default:dirt_with_grass" ,
  124. "default:dirt" ,
  125. "default:dirt_with_rainforest_litter",
  126. "default:dry_dirt",
  127. "default:dirt_with_snow",
  128. "default:dirt_with_coniferous_litter" },
  129. sidelen = 16,
  130. noise_params = {
  131. offset = -0.3,
  132. scale = 0.7,
  133. spread = {x = 100, y =100, z = 100},
  134. seed = 354,
  135. octaves = 3,
  136. persist = 1.5
  137. },
  138. fill_ratio = 0.03,
  139. biomes = {--"canapa_swamp",
  140. "cold_desert",
  141. "rainforest",
  142. "grassland_dunes",
  143. "coniferous_forest_dunes",
  144. "savanna",
  145. "taiga",
  146. "coniferous_forest",
  147. "deciduous_forest",
  148. "desert",
  149. "sandstone_desert",
  150. "cold_desert","canapa_swamp",
  151. "tundra_beach",
  152. "savanna_shore",
  153. "delicious_forest_shore",
  154. "grassland",
  155. "floatland_grassland"},
  156. y_min = 1,
  157. y_max = 3,
  158. decoration = "cannabis:canapa",
  159. height = 2,
  160. height_max = 7,
  161. spawn_by = "default:water_source",
  162. num_spawn_by = 1,
  163. })
  164. minetest.register_decoration({
  165. deco_type = "schematic",
  166. place_on = {"default:dirt_with_grass",
  167. "default:dirt",
  168. "default:sand"},
  169. sidelen = 16,
  170. noise_params = {
  171. offset = -0.3,
  172. scale = 0.7,
  173. spread = {x = 100, y = 100, z = 100},
  174. seed = 354,
  175. octaves = 3,
  176. persist = 0.7
  177. },
  178. biomes = {--"canapa_swampr",
  179. "rainforest_swamp",
  180. "savanna",
  181. "taiga",
  182. "coniferous_forest",
  183. "deciduous_forest",
  184. "desert",
  185. "sandstone_desert",
  186. "cold_desert","canapa_swamp",
  187. "tundra_beach",
  188. "savanna_shore",
  189. "delicious_forest_shore",
  190. "floatland_grassland"},
  191. y_min = 0,
  192. y_max = 0,
  193. schematic = path .. "/schematics/canapa.mts",--minetest.get_modpath("cannabis").."/schematics/canapa.mts",
  194. })
  195. end
  196. -- This file supplies hemp for the plantlife modpack
  197. -- Last revision: 2016-01-14
  198. minetest.register_node('cannabis:seedling', {
  199. description = S("Hemp (seedling)"),
  200. drawtype = 'plantlike',
  201. waving = 1,
  202. tiles = { '1hemp_seedling.png' },
  203. inventory_image = '1hemp_seedling.png',
  204. wield_image = '1hemp_seedling.png',
  205. sunlight_propagates = true,
  206. paramtype = 'light',
  207. walkable = false,
  208. groups = { snappy = 3, poisonivy=1, flora_block=1 },
  209. sounds = {"cannabis_canapa_s3"},
  210. buildable_to = true,
  211. })
  212. minetest.register_node('cannabis:sproutling', {
  213. description = S("Hemp (sproutling)"),
  214. drawtype = 'plantlike',
  215. waving = 1,
  216. tiles = { 'hemp_sproutling.png' },
  217. inventory_image = 'hemp_sproutling.png',
  218. wield_image = 'hemp_sproutling.png',
  219. sunlight_propagates = true,
  220. paramtype = 'light',
  221. walkable = false,
  222. groups = { snappy = 3, poisonivy=1, flora_block=1 },
  223. sounds = {"cannabis_canapa_s3"},
  224. buildable_to = true,
  225. })
  226. minetest.register_node('cannabis:flowering', {
  227. description = S("Hemp (flowering)"),
  228. drawtype = 'plantlike',
  229. waving = 1,
  230. tiles = { 'cannabis_canapa_flower.png' },
  231. sunlight_propagates = true,
  232. paramtype = 'light',
  233. walkable = false,
  234. selection_box = {
  235. type = "fixed",
  236. fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
  237. },
  238. groups = { snappy = 3, poisonivy=1, flora_block=1 },
  239. sounds ={"cannabis_canapa_s3"},
  240. buildable_to = true,
  241. drop = {
  242. max_items = 3,
  243. items = {
  244. {items = {"cannabis:canapa_flower"}, rarity = 1 },
  245. -- {items = {"cannabis:canapa_leaves"}, rarity = 1 },
  246. {items = {"cannabis:canapa_seed"}, rarity = 1 },
  247. }}
  248. })
  249. minetest.register_node('cannabis:climbing', {
  250. description = S("Hemp (climbing plant)"),
  251. drawtype = 'signlike',
  252. tiles = { 'hemp_climbing.png' },
  253. inventory_image = 'hemp_climbing.png',
  254. wield_image = 'hemp_climbing.png',
  255. sunlight_propagates = true,
  256. paramtype = 'light',
  257. paramtype2 = 'wallmounted',
  258. walkable = false,
  259. groups = { snappy = 3, poisonivy=1, flora_block=1 },
  260. sounds ={"cannabis_canapa_s3"},
  261. selection_box = {
  262. type = "wallmounted",
  263. --wall_side = = <default>
  264. },
  265. buildable_to = true,
  266. })