init.lua 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. local modname = minetest.get_current_modname()
  2. local S = minetest.get_translator(modname)
  3. minetest.register_node(modname .. ":bamboo",
  4. {
  5. tiles = {modname .. "_stalk.png"},
  6. description = S("Bamboo"),
  7. drawtype = "nodebox",
  8. groups = {choppy = 3},
  9. climbable = true,
  10. sunlight_propagates = true,
  11. walkable = true,
  12. is_ground_content = false,
  13. paramtype = "light",
  14. sounds =
  15. {
  16. dig = "wood_high_dig",
  17. dug = "wood_high_dug",
  18. footstep = "wood_high_footstep",
  19. place = "wood_high_place",
  20. },
  21. node_box =
  22. {
  23. type = "fixed",
  24. fixed =
  25. {
  26. {-2 / 16, -0.5, -2 / 16, 2 / 16, 0.5, 2 / 16},
  27. },
  28. }
  29. })
  30. minetest.register_abm(
  31. {
  32. label = "Bamboo growing",
  33. nodenames = {modname .. ":bamboo"},
  34. interval = 5.0,
  35. chance = 60,
  36. catch_up = true,
  37. action = function(pos)
  38. local above = {x = pos.x, y = pos.y + 1, z = pos.z}
  39. local above_node = minetest.get_node(above)
  40. if above_node.name == "air"
  41. then
  42. --pos is at top node of bamboo stalk
  43. local y = pos.y - 1
  44. local stalk
  45. local height = 0
  46. repeat
  47. stalk = minetest.get_node({x = pos.x, y = y, z = pos.z})
  48. y = y - 1
  49. height = height + 1
  50. until stalk.name ~= modname .. ":bamboo" or height > 10
  51. if height <= 10
  52. then
  53. minetest.after(0.1, minetest.set_node, above, {name = modname .. ":bamboo"})
  54. end
  55. end
  56. end,
  57. })
  58. if minetest.get_modpath("eg_mapgen")
  59. then
  60. minetest.register_decoration(
  61. {
  62. deco_type = "simple",
  63. place_on = "eg_mapgen:grass",
  64. sidelen = 8,
  65. noise_params =
  66. {
  67. offset = -0.6,
  68. scale = -0.5,
  69. seed = 490249204,
  70. spread = {x = 100, y = 100, z = 100},
  71. octaves = 3,
  72. persistence = 0.7,
  73. lacunarity = 2.0,
  74. },
  75. decoration = modname .. ":bamboo",
  76. height = 1,
  77. height_max = 11,
  78. })
  79. end