juncus.lua 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. -----------------------------------------------------------------------------------------------
  2. -- Grasses - Juncus 0.0.5
  3. -----------------------------------------------------------------------------------------------
  4. -- by Mossmanikin
  5. -- textures & ideas partly by Neuromancer
  6. -- Contains code from: biome_lib
  7. -- Looked at code from: default
  8. -----------------------------------------------------------------------------------------------
  9. -- support for i18n
  10. local S = minetest.get_translator("dryplants")
  11. abstract_dryplants.grow_juncus = function(pos)
  12. local juncus_type = math.random(2,3)
  13. local right_here = {x=pos.x, y=pos.y+1, z=pos.z}
  14. if minetest.get_node(right_here).name == "air" -- instead of check_air = true,
  15. or minetest.get_node(right_here).name == "default:junglegrass" then
  16. if juncus_type == 2 then
  17. minetest.swap_node(right_here, {name="dryplants:juncus_02"})
  18. else
  19. minetest.swap_node(right_here, {name="dryplants:juncus"})
  20. end
  21. end
  22. end
  23. minetest.register_node("dryplants:juncus", {
  24. description = S("Juncus"),
  25. drawtype = "plantlike",
  26. visual_scale = math.sqrt(8),
  27. paramtype = "light",
  28. tiles = {"dryplants_juncus_03.png"},
  29. inventory_image = "dryplants_juncus_inv.png",
  30. walkable = false,
  31. buildable_to = true,
  32. groups = {
  33. snappy=3,
  34. flammable=2,
  35. attached_node=1,
  36. flora=1
  37. --not_in_creative_inventory=1
  38. },
  39. sounds = default.node_sound_leaves_defaults(),
  40. selection_box = {
  41. type = "fixed",
  42. fixed = {-7/16, -1/2, -7/16, 7/16, 0, 7/16},
  43. },
  44. on_place = function(itemstack, placer, pointed_thing)
  45. local playername = placer:get_player_name()
  46. if minetest.is_protected(pointed_thing.above, playername) or
  47. minetest.is_protected(pointed_thing.under, playername) then
  48. minetest.chat_send_player(playername, "Someone else owns that spot.")
  49. return
  50. end
  51. local pos = pointed_thing.under
  52. local juncus_type = math.random(2,3)
  53. local right_here = {x=pos.x, y=pos.y+1, z=pos.z}
  54. if juncus_type == 2 then
  55. minetest.swap_node(right_here, {name="dryplants:juncus_02"})
  56. else
  57. minetest.swap_node(right_here, {name="dryplants:juncus"})
  58. end
  59. if not minetest.setting_getbool("creative_mode") then
  60. itemstack:take_item()
  61. end
  62. return itemstack
  63. end,
  64. })
  65. minetest.register_node("dryplants:juncus_02", {
  66. description = S("Juncus"),
  67. drawtype = "plantlike",
  68. visual_scale = math.sqrt(8),
  69. paramtype = "light",
  70. tiles = {"dryplants_juncus_02.png"},
  71. walkable = false,
  72. buildable_to = true,
  73. groups = {
  74. snappy=3,
  75. flammable=2,
  76. attached_node=1,
  77. flora=1,
  78. not_in_creative_inventory=1
  79. },
  80. sounds = default.node_sound_leaves_defaults(),
  81. selection_box = {
  82. type = "fixed",
  83. fixed = {-7/16, -1/2, -7/16, 7/16, 0, 7/16},
  84. },
  85. drop = "dryplants:juncus",
  86. })
  87. -----------------------------------------------------------------------------------------------
  88. -- GENERATE SMALL JUNCUS
  89. -----------------------------------------------------------------------------------------------
  90. -- near water or swamp
  91. biome_lib:register_generate_plant({
  92. surface = {
  93. "default:dirt_with_grass",
  94. --"default:desert_sand",
  95. --"default:sand",
  96. "stoneage:grass_with_silex",
  97. "sumpf:peat",
  98. "sumpf:sumpf"
  99. },
  100. max_count = JUNCUS_NEAR_WATER_PER_MAPBLOCK,
  101. rarity = 101 - JUNCUS_NEAR_WATER_RARITY,
  102. min_elevation = 1, -- above sea level
  103. near_nodes = {"default:water_source","sumpf:dirtywater_source","sumpf:sumpf"},
  104. near_nodes_size = 2,
  105. near_nodes_vertical = 1,
  106. near_nodes_count = 1,
  107. plantlife_limit = -0.9,
  108. },
  109. abstract_dryplants.grow_juncus
  110. )
  111. -- at dunes/beach
  112. biome_lib:register_generate_plant({
  113. surface = {
  114. --"default:dirt_with_grass",
  115. --"default:desert_sand",
  116. "default:sand",
  117. --"stoneage:grass_with_silex",
  118. --"sumpf:peat",
  119. --"sumpf:sumpf"
  120. },
  121. max_count = JUNCUS_AT_BEACH_PER_MAPBLOCK,
  122. rarity = 101 - JUNCUS_AT_BEACH_RARITY,
  123. min_elevation = 1, -- above sea level
  124. near_nodes = {"default:dirt_with_grass"},
  125. near_nodes_size = 2,
  126. near_nodes_vertical = 1,
  127. near_nodes_count = 1,
  128. plantlife_limit = -0.9,
  129. },
  130. abstract_dryplants.grow_juncus
  131. )