nodes.lua 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. -- support for i18n
  2. local S = minetest.get_translator("cavestuff")
  3. --Rocks
  4. local cbox = {
  5. type = "fixed",
  6. fixed = {-5/16, -8/16, -6/16, 5/16, -1/32, 5/16},
  7. }
  8. minetest.register_node("cavestuff:pebble_1",{
  9. description = S("Pebble"),
  10. drawtype = "mesh",
  11. mesh = "cavestuff_pebble.obj",
  12. tiles = {"undergrowth_pebble.png"},
  13. paramtype = "light",
  14. paramtype2 = "facedir",
  15. groups = {cracky=3, stone=1},
  16. selection_box = cbox,
  17. collision_box = cbox,
  18. on_place = function(itemstack, placer, pointed_thing)
  19. -- place a random pebble node
  20. local stack = ItemStack("cavestuff:pebble_"..math.random(1,2))
  21. local ret = minetest.item_place(stack, placer, pointed_thing)
  22. return ItemStack("cavestuff:pebble_1 "..itemstack:get_count()-(1-ret:get_count()))
  23. end,
  24. sounds = default.node_sound_stone_defaults(),
  25. })
  26. minetest.register_node("cavestuff:pebble_2",{
  27. drawtype = "mesh",
  28. mesh = "cavestuff_pebble.obj",
  29. tiles = {"undergrowth_pebble.png"},
  30. drop = "cavestuff:pebble_1",
  31. tiles = {"undergrowth_pebble.png"},
  32. paramtype = "light",
  33. paramtype2 = "facedir",
  34. groups = {cracky=3, stone=1, not_in_creative_inventory=1},
  35. selection_box = cbox,
  36. collision_box = cbox,
  37. sounds = default.node_sound_stone_defaults(),
  38. })
  39. minetest.register_node("cavestuff:desert_pebble_1",{
  40. description = S("Desert Pebble"),
  41. drawtype = "mesh",
  42. mesh = "cavestuff_pebble.obj",
  43. tiles = {"default_desert_stone.png"},
  44. paramtype = "light",
  45. paramtype2 = "facedir",
  46. groups = {cracky=3, stone=1},
  47. selection_box = cbox,
  48. collision_box = cbox,
  49. on_place = function(itemstack, placer, pointed_thing)
  50. -- place a random pebble node
  51. local stack = ItemStack("cavestuff:desert_pebble_"..math.random(1,2))
  52. local ret = minetest.item_place(stack, placer, pointed_thing)
  53. return ItemStack("cavestuff:desert_pebble_1 "..itemstack:get_count()-(1-ret:get_count()))
  54. end,
  55. sounds = default.node_sound_stone_defaults(),
  56. })
  57. minetest.register_node("cavestuff:desert_pebble_2",{
  58. drawtype = "mesh",
  59. mesh = "cavestuff_pebble.obj",
  60. drop = "cavestuff:desert_pebble_1",
  61. tiles = {"default_desert_stone.png"},
  62. paramtype = "light",
  63. paramtype2 = "facedir",
  64. groups = {cracky=3, stone=1, not_in_creative_inventory=1},
  65. selection_box = cbox,
  66. collision_box = cbox,
  67. sounds = default.node_sound_stone_defaults(),
  68. })
  69. --Staclactites
  70. minetest.register_node("cavestuff:stalactite_1",{
  71. drawtype="nodebox",
  72. tiles = {"undergrowth_pebble.png"},
  73. groups = {cracky=3,attached_node=1},
  74. description = S("Stalactite"),
  75. paramtype = "light",
  76. paramtype2 = "wallmounted",
  77. node_box = {
  78. type = "fixed",
  79. fixed = {
  80. {-0.187500,0.425000,-0.150003,0.162500,0.500000,0.162500},
  81. {-0.112500,0.162500,-0.100000,0.087500,0.475000,0.087500},
  82. {-0.062500,-0.275000,-0.062500,0.062500,0.500000,0.062500},
  83. {-0.037500,-0.837500,0.037500,0.037500,0.500000,-0.025000},
  84. }
  85. },
  86. on_place = function(itemstack, placer, pointed_thing)
  87. local pt = pointed_thing
  88. if minetest.get_node(pt.under).name=="default:stone"
  89. and minetest.get_node({x=pt.under.x, y=pt.under.y-1, z=pt.under.z}).name=="air"
  90. and minetest.get_node({x=pt.under.x, y=pt.under.y-2, z=pt.under.z}).name=="air" then
  91. minetest.swap_node({x=pt.under.x, y=pt.under.y-1, z=pt.under.z}, {name="cavestuff:stalactite_"..math.random(1,3)})
  92. if not minetest.setting_getbool("creative_mode") then
  93. itemstack:take_item()
  94. end
  95. end
  96. return itemstack
  97. end,
  98. })
  99. minetest.register_node("cavestuff:stalactite_2",{
  100. drawtype="nodebox",
  101. tiles = {"undergrowth_pebble.png"},
  102. groups = {cracky=3,attached_node=1,not_in_creative_inventory=1},
  103. drop = "cavestuff:stalactite_1",
  104. paramtype = "light",
  105. paramtype2 = "wallmounted",
  106. node_box = {
  107. type = "fixed",
  108. fixed = {
  109. {-0.187500,0.387500,-0.150003,0.162500,0.500000,0.162500},
  110. {-0.112500,0.112500,-0.100000,0.087500,0.475000,0.087500},
  111. {-0.062500,-0.675000,-0.062500,0.062500,0.500000,0.062500},
  112. {-0.037500,-0.975000,0.037500,0.037500,0.500000,-0.025000},
  113. }
  114. },
  115. })
  116. minetest.register_node("cavestuff:stalactite_3",{
  117. drawtype="nodebox",
  118. tiles = {"undergrowth_pebble.png"},
  119. groups = {cracky=3,attached_node=1,not_in_creative_inventory=1},
  120. drop = "cavestuff:stalactite_1",
  121. paramtype = "light",
  122. paramtype2 = "wallmounted",
  123. node_box = {
  124. type = "fixed",
  125. fixed = {
  126. {-0.187500,0.387500,-0.150003,0.162500,0.500000,0.162500},
  127. {-0.112500,0.037500,-0.100000,0.087500,0.475000,0.087500},
  128. {-0.062500,-0.437500,-0.062500,0.062500,0.500000,0.062500},
  129. {-0.037500,-1.237500,0.037500,0.037500,0.500000,-0.025000},
  130. }
  131. },
  132. })
  133. --Stalagmites