barrel_cacti.lua 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. local bc_col_box_1 = {
  2. type = 'fixed',
  3. fixed = {{-.3, -.5, -.3, .3, .0, .3}}
  4. }
  5. local bc_col_box_2 = {
  6. type = 'fixed',
  7. fixed = {{-.3, -.5, -.3, .3, .45, .3}}
  8. }
  9. local bc_col_box_3 = {
  10. type = 'fixed',
  11. fixed = {{-.3, -.5, -.3, .3, .8, .3}}
  12. }
  13. local barrel_cacti_table = { --number, desc, col_box
  14. {1, 'Small Barrel Cacti' ,bc_col_box_1},
  15. {2, 'Medium Barrel Cacti' ,bc_col_box_2},
  16. {3, 'Large Barrel Cacti' ,bc_col_box_3}
  17. }
  18. for i in ipairs (barrel_cacti_table) do
  19. local num = barrel_cacti_table[i][1]
  20. local desc = barrel_cacti_table[i][2]
  21. local col = barrel_cacti_table[i][3]
  22. minetest.register_node('desert_life:barrel_cacti_'..num, {
  23. description = desc,
  24. drawtype = 'mesh',
  25. mesh = 'dl_barrel_cacti_'..num..'.obj',
  26. tiles = {'dl_barrel_cacti.png'},
  27. groups = {oddly_breakable_by_hand=3, choppy=1},
  28. paramtype = 'light',
  29. paramtype2 = 'facedir',
  30. selection_box = col,
  31. collision_box = col,
  32. after_place_node = function(pos, placer, itemstack)
  33. local under = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
  34. local node = minetest.get_node(pos)
  35. if under.name == 'default:sand' or under.name == 'default:desert_sand' then
  36. minetest.set_node(pos, {name = 'desert_life:barrel_cacti_'..num..'_sp', param2 = node.param2})
  37. end
  38. end,
  39. })
  40. minetest.register_node('desert_life:barrel_cacti_'..num..'_sp', {
  41. description = desc,
  42. drawtype = 'mesh',
  43. mesh = 'dl_barrel_cacti_'..num..'.obj',
  44. tiles = {name='dl_barrel_cacti.png'},
  45. drop = 'desert_life:barrel_cacti_'..num,
  46. groups = {oddly_breakable_by_hand=3, choppy=1, dl_bc=1, not_in_creative_inventory=1},
  47. paramtype = 'light',
  48. paramtype2 = 'facedir',
  49. selection_box = col,
  50. collision_box = col,
  51. })
  52. end
  53. minetest.register_decoration({
  54. deco_type = "simple",
  55. place_on = {"default:desert_sand"},
  56. sidelen = 16,
  57. noise_params = {
  58. offset = .005,
  59. scale = 0.002,
  60. spread = {x = 150, y = 150, z = 150},
  61. seed = 35746584,
  62. octaves = 3,
  63. persist = 0.6
  64. },
  65. y_min = -10,
  66. y_max = 60,
  67. decoration = "desert_life:barrel_cacti_1_sp",
  68. param2 = 0,
  69. param2_max = 3,
  70. biomes = {'desert'},
  71. })
  72. minetest.register_abm{
  73. nodenames = {"group:dl_bc"},
  74. interval = 40,
  75. chance = 30,
  76. action = function(pos)
  77. local node = minetest.get_node(pos)
  78. if node.name == 'desert_life:barrel_cacti_1_sp' then
  79. minetest.set_node(pos, {name = "desert_life:barrel_cacti_2_sp", param2 = node.param2})
  80. elseif node.name == 'desert_life:barrel_cacti_2_sp' then
  81. minetest.set_node(pos, {name = "desert_life:barrel_cacti_3_sp", param2 = node.param2})
  82. elseif node.name == 'desert_life:barrel_cacti_3_sp' then
  83. desert_life.spread('desert_life:barrel_cacti_1_sp', pos, 2, 'default:desert_sand', 'air', 48)
  84. end
  85. end,
  86. }