Vanessa's plantlife modpack
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

412 lines
14KB

  1. -----------------------------------------------------------------------------------------------
  2. -- Grasses - Reedmace 0.1.1
  3. -----------------------------------------------------------------------------------------------
  4. -- by Mossmanikin
  5. -- textures & ideas partly by Neuromancer
  6. -- License (everything): WTFPL
  7. -- Contains code from: biome_lib
  8. -- Looked at code from: default, trees
  9. -----------------------------------------------------------------------------------------------
  10. -- NOTES (from wikipedia, some of this might get implemented)
  11. -- rhizomes are edible
  12. -- outer portion of young plants can be peeled and the heart can be eaten raw or boiled and eaten like asparagus
  13. -- leaf bases can be eaten raw or cooked
  14. -- sheath can be removed from the developing green flower spike, which can then be boiled and eaten like corn on the cob
  15. -- pollen can be collected and used as a flour supplement or thickener
  16. -- Typha stems and leaves can be used to make paper
  17. -- The seed hairs were used by some Native American groups as tinder for starting fires
  18. -----------------------------------------------------------------------------------------------
  19. -- REEDMACE SHAPES
  20. -----------------------------------------------------------------------------------------------
  21. abstract_dryplants.grow_reedmace = function(pos)
  22. local size = math.random(1,3)
  23. local spikes = math.random(1,3)
  24. local pos_01 = {x = pos.x, y = pos.y + 1, z = pos.z}
  25. local pos_02 = {x = pos.x, y = pos.y + 2, z = pos.z}
  26. local pos_03 = {x = pos.x, y = pos.y + 3, z = pos.z}
  27. if minetest.get_node(pos_01).name == "air" -- bug fix
  28. or minetest.get_node(pos_01).name == "dryplants:reedmace_sapling" then
  29. if minetest.get_node(pos_02).name ~= "air" then
  30. minetest.set_node(pos_01, {name="dryplants:reedmace_top"})
  31. elseif minetest.get_node(pos_03).name ~= "air" then
  32. minetest.set_node(pos_01, {name="dryplants:reedmace_height_2"})
  33. elseif size == 1 then
  34. minetest.set_node(pos_01, {name="dryplants:reedmace_top"})
  35. elseif size == 2 then
  36. minetest.set_node(pos_01, {name="dryplants:reedmace_height_2"})
  37. elseif size == 3 then
  38. if spikes == 1 then
  39. minetest.set_node(pos_01, {name="dryplants:reedmace_height_3_spikes"})
  40. else
  41. minetest.set_node(pos_01, {name="dryplants:reedmace_height_3"})
  42. end
  43. end
  44. end
  45. end
  46. abstract_dryplants.grow_reedmace_water = function(pos)
  47. local size = math.random(1,3)
  48. local spikes = math.random(1,3)
  49. local pos_01 = {x = pos.x, y = pos.y + 1, z = pos.z}
  50. local pos_02 = {x = pos.x, y = pos.y + 2, z = pos.z}
  51. local pos_03 = {x = pos.x, y = pos.y + 3, z = pos.z}
  52. local pos_04 = {x = pos.x, y = pos.y + 4, z = pos.z}
  53. minetest.add_entity(pos_01, "dryplants:reedmace_water_entity")
  54. if minetest.get_node(pos_02).name == "air" then -- bug fix
  55. if minetest.get_node(pos_03).name ~= "air" then
  56. minetest.set_node(pos_02, {name="dryplants:reedmace_top"})
  57. elseif minetest.get_node(pos_04).name ~= "air" then
  58. minetest.set_node(pos_02, {name="dryplants:reedmace_height_2"})
  59. elseif size == 1 then
  60. minetest.set_node(pos_02, {name="dryplants:reedmace_top"})
  61. elseif size == 2 then
  62. minetest.set_node(pos_02, {name="dryplants:reedmace_height_2"})
  63. elseif size == 3 then
  64. if spikes == 1 then
  65. minetest.set_node(pos_02, {name="dryplants:reedmace_height_3_spikes"})
  66. else
  67. minetest.set_node(pos_02, {name="dryplants:reedmace_height_3"})
  68. end
  69. end
  70. end
  71. end
  72. -----------------------------------------------------------------------------------------------
  73. -- REEDMACE SPIKES
  74. -----------------------------------------------------------------------------------------------
  75. minetest.register_node("dryplants:reedmace_spikes", {
  76. description = "Reedmace",
  77. drawtype = "plantlike",
  78. paramtype = "light",
  79. tiles = {"dryplants_reedmace_spikes.png"},
  80. inventory_image = "dryplants_reedmace_spikes.png",
  81. walkable = false,
  82. groups = {
  83. snappy=3,
  84. flammable=2,
  85. not_in_creative_inventory=1
  86. },
  87. drop = 'dryplants:reedmace_sapling',
  88. sounds = default.node_sound_leaves_defaults(),
  89. selection_box = {
  90. type = "fixed",
  91. fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
  92. },
  93. })
  94. -----------------------------------------------------------------------------------------------
  95. -- REEDMACE height: 1
  96. -----------------------------------------------------------------------------------------------
  97. minetest.register_node("dryplants:reedmace_top", {
  98. description = "Reedmace, height: 1",
  99. drawtype = "plantlike",
  100. paramtype = "light",
  101. tiles = {"dryplants_reedmace_top.png"},
  102. inventory_image = "dryplants_reedmace_top.png",
  103. walkable = false,
  104. groups = {
  105. snappy=3,
  106. flammable=2,
  107. not_in_creative_inventory=1
  108. },
  109. drop = 'dryplants:reedmace_sapling',
  110. sounds = default.node_sound_leaves_defaults(),
  111. selection_box = {
  112. type = "fixed",
  113. fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
  114. },
  115. })
  116. -----------------------------------------------------------------------------------------------
  117. -- REEDMACE height: 2
  118. -----------------------------------------------------------------------------------------------
  119. minetest.register_node("dryplants:reedmace_height_2", {
  120. description = "Reedmace, height: 2",
  121. drawtype = "plantlike",
  122. visual_scale = 2,
  123. paramtype = "light",
  124. tiles = {"dryplants_reedmace_height_2.png"},
  125. inventory_image = "dryplants_reedmace_top.png",
  126. walkable = false,
  127. groups = {
  128. snappy=3,
  129. flammable=2--,
  130. --not_in_creative_inventory=1
  131. },
  132. drop = 'dryplants:reedmace_sapling',
  133. sounds = default.node_sound_leaves_defaults(),
  134. selection_box = {
  135. type = "fixed",
  136. fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
  137. },
  138. })
  139. -----------------------------------------------------------------------------------------------
  140. -- REEDMACE height: 3
  141. -----------------------------------------------------------------------------------------------
  142. minetest.register_node("dryplants:reedmace_height_3", {
  143. description = "Reedmace, height: 3",
  144. drawtype = "plantlike",
  145. visual_scale = 2,
  146. paramtype = "light",
  147. tiles = {"dryplants_reedmace_height_3.png"},
  148. inventory_image = "dryplants_reedmace_top.png",
  149. walkable = false,
  150. groups = {
  151. snappy=3,
  152. flammable=2--,
  153. --not_in_creative_inventory=1
  154. },
  155. drop = 'dryplants:reedmace_sapling',
  156. sounds = default.node_sound_leaves_defaults(),
  157. selection_box = {
  158. type = "fixed",
  159. fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
  160. },
  161. })
  162. -----------------------------------------------------------------------------------------------
  163. -- REEDMACE height: 3 & Spikes
  164. -----------------------------------------------------------------------------------------------
  165. minetest.register_node("dryplants:reedmace_height_3_spikes", {
  166. description = "Reedmace, height: 3 & Spikes",
  167. drawtype = "plantlike",
  168. visual_scale = 2,
  169. paramtype = "light",
  170. tiles = {"dryplants_reedmace_height_3_spikes.png"},
  171. inventory_image = "dryplants_reedmace_top.png",
  172. walkable = false,
  173. groups = {
  174. snappy=3,
  175. flammable=2--,
  176. --not_in_creative_inventory=1
  177. },
  178. drop = 'dryplants:reedmace_sapling',
  179. sounds = default.node_sound_leaves_defaults(),
  180. selection_box = {
  181. type = "fixed",
  182. fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
  183. },
  184. })
  185. -----------------------------------------------------------------------------------------------
  186. -- REEDMACE STEMS
  187. -----------------------------------------------------------------------------------------------
  188. minetest.register_node("dryplants:reedmace", {
  189. description = "Reedmace",
  190. drawtype = "plantlike",
  191. paramtype = "light",
  192. tiles = {"dryplants_reedmace.png"},
  193. inventory_image = "dryplants_reedmace.png",
  194. walkable = false,
  195. groups = {
  196. snappy=3,
  197. flammable=2,
  198. not_in_creative_inventory=1
  199. },
  200. drop = 'dryplants:reedmace_sapling',
  201. sounds = default.node_sound_leaves_defaults(),
  202. selection_box = {
  203. type = "fixed",
  204. fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
  205. },
  206. after_destruct = function(pos,oldnode)
  207. local node = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
  208. if node.name == "dryplants:reedmace_top"
  209. or node.name == "dryplants:reedmace_spikes" then
  210. minetest.dig_node({x=pos.x,y=pos.y+1,z=pos.z})
  211. minetest.add_item(pos,"dryplants:reedmace_sapling")
  212. end
  213. end,
  214. })
  215. -----------------------------------------------------------------------------------------------
  216. -- REEDMACE BOTTOM
  217. -----------------------------------------------------------------------------------------------
  218. minetest.register_node("dryplants:reedmace_bottom", {
  219. description = "Reedmace",
  220. drawtype = "plantlike",
  221. paramtype = "light",
  222. tiles = {"dryplants_reedmace_bottom.png"},
  223. inventory_image = "dryplants_reedmace_bottom.png",
  224. walkable = false,
  225. groups = {
  226. snappy=3,
  227. flammable=2,
  228. not_in_creative_inventory=1
  229. },
  230. drop = 'dryplants:reedmace_sapling',
  231. sounds = default.node_sound_leaves_defaults(),
  232. selection_box = {
  233. type = "fixed",
  234. fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
  235. },
  236. after_destruct = function(pos,oldnode)
  237. local node = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
  238. if node.name == "dryplants:reedmace"
  239. or node.name == "dryplants:reedmace_top"
  240. or node.name == "dryplants:reedmace_spikes" then
  241. minetest.dig_node({x=pos.x,y=pos.y+1,z=pos.z})
  242. minetest.add_item(pos,"dryplants:reedmace_sapling")
  243. end
  244. end,
  245. })
  246. -----------------------------------------------------------------------------------------------
  247. -- REEDMACE "SAPLING" (the drop from the above)
  248. -----------------------------------------------------------------------------------------------
  249. minetest.register_node("dryplants:reedmace_sapling", {
  250. description = "Reedmace",
  251. drawtype = "plantlike",
  252. paramtype = "light",
  253. tiles = {"dryplants_reedmace_sapling.png"},
  254. inventory_image = "dryplants_reedmace_sapling.png",
  255. walkable = false,
  256. groups = {
  257. snappy=3,
  258. flammable=2,
  259. attached_node=1
  260. },
  261. sounds = default.node_sound_leaves_defaults(),
  262. selection_box = {
  263. type = "fixed",
  264. fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
  265. },
  266. })
  267. -- abm
  268. minetest.register_abm({
  269. nodenames = "dryplants:reedmace_sapling",
  270. interval = REEDMACE_GROWING_TIME,
  271. chance = 100/REEDMACE_GROWING_CHANCE,
  272. action = function(pos, node, _, _)
  273. if string.find(minetest.get_node({x = pos.x + 1, y = pos.y, z = pos.z }).name, "default:water")
  274. or string.find(minetest.get_node({x = pos.x, y = pos.y, z = pos.z + 1}).name, "default:water")
  275. or string.find(minetest.get_node({x = pos.x - 1, y = pos.y, z = pos.z }).name, "default:water")
  276. or string.find(minetest.get_node({x = pos.x, y = pos.y, z = pos.z - 1}).name, "default:water") then
  277. if minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z}).name == "air" then
  278. abstract_dryplants.grow_reedmace_water({x = pos.x, y = pos.y - 1, z = pos.z})
  279. end
  280. minetest.set_node({x=pos.x, y=pos.y, z=pos.z}, {name="default:water_source"})
  281. else
  282. abstract_dryplants.grow_reedmace({x = pos.x, y = pos.y - 1, z = pos.z})
  283. end
  284. end
  285. })
  286. -----------------------------------------------------------------------------------------------
  287. -- REEDMACE WATER (for entity)
  288. -----------------------------------------------------------------------------------------------
  289. minetest.register_node("dryplants:reedmace_water", {
  290. description = "Reedmace",
  291. drawtype = "plantlike",
  292. paramtype = "light",
  293. tiles = {"dryplants_reedmace_water.png"},
  294. inventory_image = "dryplants_reedmace_water.png",
  295. groups = {not_in_creative_inventory=1},
  296. selection_box = {
  297. type = "fixed",
  298. fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
  299. },
  300. })
  301. -----------------------------------------------------------------------------------------------
  302. -- REEDMACE WATER ENTITY
  303. -----------------------------------------------------------------------------------------------
  304. minetest.register_entity("dryplants:reedmace_water_entity",{
  305. visual = "mesh",
  306. mesh = "plantlike.obj",
  307. visual_size = {x=10, y=10},
  308. textures = {"dryplants_reedmace_water.png"},
  309. collisionbox = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3},
  310. on_punch = function(self, puncher)
  311. if puncher:is_player() and puncher:get_inventory() then
  312. if not minetest.setting_getbool("creative_mode") then
  313. puncher:get_inventory():add_item("main", "dryplants:reedmace_sapling")
  314. end
  315. self.object:remove()
  316. end
  317. end,
  318. })
  319. -----------------------------------------------------------------------------------------------
  320. -- SPAWN REEDMACE
  321. -----------------------------------------------------------------------------------------------
  322. --[[biome_lib:spawn_on_surfaces({
  323. spawn_delay = 1200,
  324. spawn_plants = {"dryplants:reedmace_sapling"},
  325. spawn_chance = 400,
  326. spawn_surfaces = {
  327. "default:dirt_with_grass",
  328. "default:desert_sand",
  329. "default:sand",
  330. "dryplants:grass_short",
  331. "stoneage:grass_with_silex"
  332. },
  333. seed_diff = 329,
  334. near_nodes = {"default:water_source"},
  335. near_nodes_size = 2,
  336. near_nodes_vertical = 1,
  337. near_nodes_count = 1,
  338. })]]
  339. -----------------------------------------------------------------------------------------------
  340. -- GENERATE REEDMACE
  341. -----------------------------------------------------------------------------------------------
  342. -- near water or swamp
  343. biome_lib:register_generate_plant({
  344. surface = {
  345. "default:dirt_with_grass",
  346. "default:desert_sand",
  347. "stoneage:grass_with_silex",
  348. "sumpf:peat",
  349. "sumpf:sumpf"
  350. },
  351. max_count = REEDMACE_NEAR_WATER_PER_MAPBLOCK,
  352. rarity = 101 - REEDMACE_NEAR_WATER_RARITY,
  353. --rarity = 60,
  354. min_elevation = 1, -- above sea level
  355. near_nodes = {"default:water_source","sumpf:dirtywater_source","sumpf:sumpf"},
  356. near_nodes_size = 2,
  357. near_nodes_vertical = 1,
  358. near_nodes_count = 1,
  359. plantlife_limit = -0.9,
  360. },
  361. abstract_dryplants.grow_reedmace
  362. )
  363. -- in water
  364. biome_lib:register_generate_plant({
  365. surface = {
  366. "default:dirt",
  367. "default:dirt_with_grass",
  368. --"default:desert_sand",
  369. --"stoneage:grass_with_silex",
  370. "stoneage:sand_with_silex",
  371. "sumpf:peat",
  372. "sumpf:sumpf"
  373. },
  374. max_count = REEDMACE_IN_WATER_PER_MAPBLOCK,
  375. rarity = 101 - REEDMACE_IN_WATER_RARITY,
  376. --rarity = 35,
  377. min_elevation = 0, -- a bit below sea level
  378. max_elevation = 0, -- ""
  379. near_nodes = {"default:water_source","sumpf:dirtywater_source"},
  380. near_nodes_size = 1,
  381. near_nodes_count = 1,
  382. plantlife_limit = -0.9,
  383. },
  384. abstract_dryplants.grow_reedmace_water
  385. )
  386. -- for oases & tropical beaches & tropical swamps
  387. biome_lib:register_generate_plant({
  388. surface = {
  389. "default:sand",
  390. "sumpf:sumpf"
  391. },
  392. max_count = REEDMACE_FOR_OASES_PER_MAPBLOCK,
  393. rarity = 101 - REEDMACE_FOR_OASES_RARITY,
  394. --rarity = 10,
  395. neighbors = {"default:water_source","sumpf:dirtywater_source","sumpf:sumpf"},
  396. ncount = 1,
  397. min_elevation = 1, -- above sea level
  398. near_nodes = {"default:desert_sand","sumpf:sumpf"},
  399. near_nodes_size = 2,
  400. near_nodes_vertical = 1,
  401. near_nodes_count = 1,
  402. plantlife_limit = -0.9,
  403. },
  404. abstract_dryplants.grow_reedmace
  405. )