fern.lua 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. -----------------------------------------------------------------------------------------------
  2. -- Ferns - Fern 0.1.0
  3. -----------------------------------------------------------------------------------------------
  4. -- by Mossmanikin
  5. -- Contains code from: biome_lib
  6. -- Looked at code from: default, flowers, painting, trees
  7. -- Dependencies: biome_lib
  8. -- Supports: dryplants, stoneage, sumpf
  9. -----------------------------------------------------------------------------------------------
  10. -- some inspiration from here
  11. -- https://en.wikipedia.org/wiki/Athyrium_yokoscense
  12. -- http://www.mygarden.net.au/gardening/athyrium-yokoscense/3900/1
  13. -----------------------------------------------------------------------------------------------
  14. assert(abstract_ferns.config.enable_lady_fern == true)
  15. -- support for i18n
  16. local S = minetest.get_translator("ferns")
  17. -- Maintain backward compatibilty
  18. -- minetest-0.5: Begin
  19. local default_ferns = minetest.registered_items["default:fern_1"] or false
  20. if default_ferns then
  21. minetest.register_alias("ferns:fern_03", "default:fern_3")
  22. minetest.register_alias("ferns:fern_02", "default:fern_2")
  23. minetest.register_alias("ferns:fern_01", "default:fern_1")
  24. end
  25. -- minetest-0.5: End
  26. minetest.register_alias("archaeplantae:fern", "ferns:fern_03")
  27. minetest.register_alias("archaeplantae:fern_mid", "ferns:fern_02")
  28. minetest.register_alias("archaeplantae:fern_small", "ferns:fern_01")
  29. minetest.register_alias("ferns:fern_04", "ferns:fern_02") -- for placing
  30. local nodenames = {}
  31. local function create_nodes()
  32. local images = { "ferns_fern.png", "ferns_fern_mid.png", "ferns_fern_big.png" }
  33. local vscales = { 1, math.sqrt(8), math.sqrt(11) }
  34. local descs = { S("Lady-fern (Athyrium)"), nil, nil }
  35. for i = 1, 3 do
  36. local node_on_place = nil
  37. if i == 1 then
  38. node_on_place = function(itemstack, placer, pointed_thing)
  39. -- place a random fern
  40. local stack = ItemStack("ferns:fern_0"..math.random(1,4))
  41. local ret = minetest.item_place(stack, placer, pointed_thing)
  42. return ItemStack("ferns:fern_01 "..itemstack:get_count()-(1-ret:get_count())) -- TODO FIXME?
  43. end
  44. end
  45. nodenames[i] = "ferns:fern_"..string.format("%02d", i)
  46. minetest.register_node(nodenames[i], {
  47. description = descs[i] or (S("Lady-fern (Athyrium)").." " .. string.format("%02d", i)),
  48. inventory_image = "ferns_fern.png",
  49. drawtype = "plantlike",
  50. visual_scale = vscales[i],
  51. paramtype = "light",
  52. tiles = { images[i] },
  53. walkable = false,
  54. buildable_to = true,
  55. groups = {snappy=3,flammable=2,attached_node=1,not_in_creative_inventory=1},
  56. sounds = default.node_sound_leaves_defaults(),
  57. selection_box = {
  58. type = "fixed",
  59. fixed = {-7/16, -1/2, -7/16, 7/16, 0, 7/16},
  60. },
  61. drop = "ferns:fern_01",
  62. on_place = node_on_place
  63. })
  64. end
  65. end
  66. -----------------------------------------------------------------------------------------------
  67. -- Init
  68. -----------------------------------------------------------------------------------------------
  69. if default_ferns then
  70. for i = 1, 3 do
  71. nodenames[i] = "ferns:fern_"..string.format("%02d", i)
  72. end
  73. else
  74. create_nodes()
  75. end
  76. -----------------------------------------------------------------------------------------------
  77. -- Spawning
  78. -----------------------------------------------------------------------------------------------
  79. if abstract_ferns.config.lady_ferns_near_tree == true then
  80. biome_lib:register_generate_plant({ -- near trees (woodlands)
  81. surface = {
  82. "default:dirt_with_grass",
  83. "default:mossycobble",
  84. "default:desert_sand",
  85. "default:sand",
  86. "default:jungletree",
  87. "stoneage:grass_with_silex",
  88. "sumpf:sumpf"
  89. },
  90. max_count = 30,
  91. rarity = 62,--63,
  92. min_elevation = 1, -- above sea level
  93. near_nodes = {"group:tree"},
  94. near_nodes_size = 3,--4,
  95. near_nodes_vertical = 2,--3,
  96. near_nodes_count = 1,
  97. plantlife_limit = -0.9,
  98. humidity_max = -1.0,
  99. humidity_min = 0.4,
  100. temp_max = -0.5, -- 55 °C (too hot?)
  101. temp_min = 0.75, -- -12 °C
  102. random_facedir = { 0, 179 },
  103. },
  104. nodenames
  105. )
  106. end
  107. if abstract_ferns.config.lady_ferns_near_rock == true then
  108. biome_lib:register_generate_plant({ -- near stone (mountains)
  109. surface = {
  110. "default:dirt_with_grass",
  111. "default:mossycobble",
  112. "group:falling_node",
  113. --"default:jungletree",
  114. "stoneage:grass_with_silex",
  115. "sumpf:sumpf"
  116. },
  117. max_count = 35,
  118. rarity = 40,
  119. min_elevation = 1, -- above sea level
  120. near_nodes = {"group:stone"},
  121. near_nodes_size = 1,
  122. near_nodes_count = 16,
  123. plantlife_limit = -0.9,
  124. humidity_max = -1.0,
  125. humidity_min = 0.4,
  126. temp_max = -0.5, -- 55 °C (too hot?)
  127. temp_min = 0.75, -- -12 °C
  128. random_facedir = { 0, 179 },
  129. },
  130. nodenames
  131. )
  132. end
  133. if abstract_ferns.config.lady_ferns_near_ores == true then -- this one causes a huge fps drop
  134. biome_lib:register_generate_plant({ -- near ores (potential mining sites)
  135. surface = {
  136. "default:dirt_with_grass",
  137. "default:mossycobble",
  138. "default:stone_with_coal",
  139. "default:stone_with_iron",
  140. "default:stone_with_tin", -- minetest >= 0.4.16
  141. "moreores:mineral_tin",
  142. "moreores:mineral_silver",
  143. "sumpf:sumpf"
  144. },
  145. max_count = 1200,--1600, -- maybe too much? :D
  146. rarity = 25,--15,
  147. min_elevation = 1, -- above sea level
  148. near_nodes = {
  149. "default:stone_with_iron",
  150. --"default:stone_with_copper",
  151. --"default:stone_with_mese",
  152. --"default:stone_with_gold",
  153. --"default:stone_with_diamond",
  154. "default:stone_with_tin", -- minetest >= 0.4.16
  155. "moreores:mineral_tin",
  156. "moreores:mineral_silver"
  157. --"moreores:mineral_mithril"
  158. },
  159. near_nodes_size = 2,
  160. near_nodes_vertical = 4,--5,--6,
  161. near_nodes_count = 2,--3,
  162. plantlife_limit = -0.9,
  163. humidity_max = -1.0,
  164. humidity_min = 0.4,
  165. temp_max = -0.5, -- 55 °C (too hot?)
  166. temp_min = 0.75, -- -12 °C
  167. random_facedir = { 0, 179 },
  168. },
  169. nodenames
  170. )
  171. end
  172. if abstract_ferns.config.lady_ferns_in_groups == true then -- this one is meant as a replacement of Ferns_near_Ores
  173. biome_lib:register_generate_plant({
  174. surface = {
  175. "default:dirt_with_grass",
  176. "default:mossycobble",
  177. "default:stone_with_coal",
  178. "default:stone_with_iron",
  179. "default:stone_with_tin", -- minetest >= 0.4.16
  180. "moreores:mineral_tin",
  181. "moreores:mineral_silver",
  182. "sumpf:sumpf"
  183. },
  184. max_count = 70,
  185. rarity = 25,--15,
  186. min_elevation = 1, -- above sea level
  187. near_nodes = {
  188. "default:stone"
  189. },
  190. near_nodes_size = 2,
  191. near_nodes_vertical = 2,--6,
  192. near_nodes_count = 3,
  193. plantlife_limit = -0.9,
  194. humidity_max = -1.0,
  195. humidity_min = 0.4,
  196. temp_max = -0.5, -- 55 °C (too hot?)
  197. temp_min = 0.75, -- -12 °C
  198. random_facedir = { 0, 179 },
  199. },
  200. nodenames
  201. )
  202. end