init.lua 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. local simple_nodes = {
  2. footstep = { "Footstep Sound Node", "soundstuff_node_footstep.png" },
  3. dig = { "Dig Sound Node", "soundstuff_node_dig.png" },
  4. dug = { "Dug Sound Node", "soundstuff_node_dug.png" },
  5. place = { "Place Sound Node", "soundstuff_node_place.png" },
  6. place_failed = { "Place Failed Sound Node", "soundstuff_node_place_failed.png" },
  7. }
  8. for k,v in pairs(simple_nodes) do
  9. minetest.register_node("soundstuff:"..k, {
  10. description = v[1],
  11. tiles = {"soundstuff_node_sound.png","soundstuff_node_sound.png",v[2]},
  12. groups = {dig_immediate=2},
  13. sounds = {
  14. [k] = { name = "soundstuff_mono", gain = 1.0 },
  15. }
  16. })
  17. end
  18. minetest.register_node("soundstuff:place_failed_attached", {
  19. description = "Attached Place Failed Sound Node",
  20. tiles = {"soundstuff_node_sound.png", "soundstuff_node_sound.png", "soundstuff_node_place_failed.png"},
  21. groups = {dig_immediate=2, attached_node=1},
  22. drawtype = "nodebox",
  23. paramtype = "light",
  24. node_box = { type = "fixed", fixed = {
  25. { -7/16, -7/16, -7/16, 7/16, 7/16, 7/16 },
  26. { -0.5, -0.5, -0.5, 0.5, -7/16, 0.5 },
  27. }},
  28. sounds = {
  29. place_failed = { name = "soundstuff_mono", gain = 1.0 },
  30. },
  31. })
  32. minetest.register_node("soundstuff:fall", {
  33. description = "Fall Sound Node",
  34. tiles = {"soundstuff_node_sound.png", "soundstuff_node_sound.png", "soundstuff_node_fall.png"},
  35. groups = {dig_immediate=2, falling_node=1},
  36. sounds = {
  37. fall = { name = "soundstuff_mono", gain = 1.0 },
  38. }
  39. })
  40. minetest.register_node("soundstuff:fall_attached", {
  41. description = "Attached Fall Sound Node",
  42. tiles = {"soundstuff_node_sound.png", "soundstuff_node_sound.png", "soundstuff_node_fall.png"},
  43. groups = {dig_immediate=2, attached_node=1},
  44. drawtype = "nodebox",
  45. paramtype = "light",
  46. node_box = { type = "fixed", fixed = {
  47. { -7/16, -7/16, -7/16, 7/16, 7/16, 7/16 },
  48. { -0.5, -0.5, -0.5, 0.5, -7/16, 0.5 },
  49. }},
  50. sounds = {
  51. fall = { name = "soundstuff_mono", gain = 1.0 },
  52. }
  53. })
  54. minetest.register_node("soundstuff:footstep_liquid", {
  55. description = "Liquid Footstep Sound Node",
  56. drawtype = "liquid",
  57. tiles = {
  58. "soundstuff_node_sound.png^[colorize:#0000FF:127^[opacity:190",
  59. },
  60. special_tiles = {
  61. {name = "soundstuff_node_sound.png^[colorize:#0000FF:127^[opacity:190",
  62. backface_culling = false},
  63. {name = "soundstuff_node_sound.png^[colorize:#0000FF:127^[opacity:190",
  64. backface_culling = true},
  65. },
  66. liquids_pointable = true,
  67. liquidtype = "source",
  68. liquid_alternative_flowing = "soundstuff:footstep_liquid",
  69. liquid_alternative_source = "soundstuff:footstep_liquid",
  70. liquid_renewable = false,
  71. liquid_range = 0,
  72. liquid_viscosity = 0,
  73. use_texture_alpha = "blend",
  74. paramtype = "light",
  75. walkable = false,
  76. pointable = false,
  77. diggable = false,
  78. buildable_to = true,
  79. is_ground_content = false,
  80. post_effect_color = {a = 64, r = 0, g = 0, b = 200},
  81. sounds = {
  82. footstep = { name = "soundstuff_mono", gain = 1.0 },
  83. }
  84. })
  85. minetest.register_node("soundstuff:footstep_climbable", {
  86. description = "Climbable Footstep Sound Node",
  87. drawtype = "allfaces",
  88. tiles = {
  89. "soundstuff_node_climbable.png",
  90. },
  91. paramtype = "light",
  92. sunlight_propagates = true,
  93. walkable = false,
  94. climbable = true,
  95. is_ground_content = false,
  96. groups = { dig_immediate = 2 },
  97. sounds = {
  98. footstep = { name = "soundstuff_mono", gain = 1.0 },
  99. }
  100. })
  101. minetest.register_craftitem("soundstuff:eat", {
  102. description = "Eat Sound Item".."\n"..
  103. "Makes a sound when 'eaten' (with punch key)",
  104. inventory_image = "soundstuff_eat.png",
  105. on_use = minetest.item_eat(0),
  106. sound = {
  107. eat = { name = "soundstuff_mono", gain = 1.0 },
  108. }
  109. })
  110. minetest.register_tool("soundstuff:breaks", {
  111. description = "Break Sound Tool".."\n"..
  112. "Digs cracky=3 and more".."\n"..
  113. "Makes a sound when it breaks",
  114. inventory_image = "soundstuff_node_dug.png",
  115. sound = {
  116. breaks = { name = "soundstuff_mono", gain = 1.0 },
  117. },
  118. tool_capabilities = {
  119. max_drop_level=0,
  120. groupcaps={
  121. cracky={times={[2]=2.00, [3]=1.20}, uses=1, maxlevel=0},
  122. choppy={times={[2]=2.00, [3]=1.20}, uses=1, maxlevel=0},
  123. snappy={times={[2]=2.00, [3]=1.20}, uses=1, maxlevel=0},
  124. crumbly={times={[2]=2.00, [3]=1.20}, uses=1, maxlevel=0},
  125. },
  126. },
  127. })
  128. -- Plays sound repeatedly
  129. minetest.register_node("soundstuff:positional", {
  130. description = "Positional Sound Node",
  131. on_construct = function(pos)
  132. local timer = minetest.get_node_timer(pos)
  133. timer:start(0)
  134. end,
  135. on_timer = function(pos, elapsed)
  136. local node = minetest.get_node(pos)
  137. local dist = node.param2
  138. if dist == 0 then
  139. dist = nil
  140. end
  141. minetest.sound_play("soundstuff_mono", { pos = pos, max_hear_distance = dist })
  142. local timer = minetest.get_node_timer(pos)
  143. timer:start(0.7)
  144. end,
  145. on_rightclick = function(pos, node, clicker)
  146. node.param2 = (node.param2 + 1) % 64
  147. minetest.set_node(pos, node)
  148. if clicker and clicker:is_player() then
  149. local dist = node.param2
  150. local diststr
  151. if dist == 0 then
  152. diststr = "<default>"
  153. else
  154. diststr = tostring(dist)
  155. end
  156. minetest.chat_send_player(clicker:get_player_name(), "max_hear_distance = " .. diststr)
  157. end
  158. end,
  159. groups = { dig_immediate = 2 },
  160. tiles = { "soundstuff_node_sound.png" },
  161. })