sound_event_items.lua 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. local simple_nodes = {
  2. footstep = { "Footstep Sound Node", "soundstuff_node_footstep.png", "Plays sound when you step on it" },
  3. dig = { "Dig Sound Node", "soundstuff_node_dig.png", "Plays sound when you dig it" },
  4. dug = { "Dug Sound Node", "soundstuff_node_dug.png", "Plays sound when you've dug it" },
  5. place = { "Place Sound Node", "soundstuff_node_place.png", "Plays sound when you place it" },
  6. place_failed = { "Place Failed Sound Node", "soundstuff_node_place_failed.png", "Plays sound when you try to place it but failed" },
  7. }
  8. for k,v in pairs(simple_nodes) do
  9. minetest.register_node("soundstuff:"..k, {
  10. description = v[1].."\n"..v[3],
  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".."\n"..
  20. "Attached to the floor; plays a sound when you try to place it but failed",
  21. tiles = {"soundstuff_node_sound.png", "soundstuff_node_sound.png", "soundstuff_node_place_failed.png"},
  22. groups = {dig_immediate=2, attached_node=1},
  23. drawtype = "nodebox",
  24. paramtype = "light",
  25. node_box = { type = "fixed", fixed = {
  26. { -7/16, -7/16, -7/16, 7/16, 7/16, 7/16 },
  27. { -0.5, -0.5, -0.5, 0.5, -7/16, 0.5 },
  28. }},
  29. sounds = {
  30. place_failed = { name = "soundstuff_mono", gain = 1.0 },
  31. },
  32. })
  33. minetest.register_node("soundstuff:fall", {
  34. description = "Fall Sound Node".."\n"..
  35. "Falls and plays sound if node below is gone",
  36. tiles = {"soundstuff_node_sound.png", "soundstuff_node_sound.png", "soundstuff_node_fall.png"},
  37. groups = {dig_immediate=2, falling_node=1},
  38. sounds = {
  39. fall = { name = "soundstuff_mono", gain = 1.0 },
  40. }
  41. })
  42. minetest.register_node("soundstuff:fall_attached", {
  43. description = "Attached Fall Sound Node".."\n"..
  44. "Drops as item and plays sound if node below is gone",
  45. tiles = {"soundstuff_node_sound.png", "soundstuff_node_sound.png", "soundstuff_node_fall.png"},
  46. groups = {dig_immediate=2, attached_node=1},
  47. drawtype = "nodebox",
  48. paramtype = "light",
  49. node_box = { type = "fixed", fixed = {
  50. { -7/16, -7/16, -7/16, 7/16, 7/16, 7/16 },
  51. { -0.5, -0.5, -0.5, 0.5, -7/16, 0.5 },
  52. }},
  53. sounds = {
  54. fall = { name = "soundstuff_mono", gain = 1.0 },
  55. }
  56. })
  57. minetest.register_node("soundstuff:footstep_liquid", {
  58. description = "Liquid Footstep Sound Node".."\n"..
  59. "Plays sound when moving inside it; swimmable",
  60. drawtype = "liquid",
  61. tiles = {
  62. "soundstuff_node_sound.png^[colorize:#0000FF:127^[opacity:190",
  63. },
  64. special_tiles = {
  65. {name = "soundstuff_node_sound.png^[colorize:#0000FF:127^[opacity:190",
  66. backface_culling = false},
  67. {name = "soundstuff_node_sound.png^[colorize:#0000FF:127^[opacity:190",
  68. backface_culling = true},
  69. },
  70. liquids_pointable = true,
  71. liquidtype = "source",
  72. liquid_alternative_flowing = "soundstuff:footstep_liquid",
  73. liquid_alternative_source = "soundstuff:footstep_liquid",
  74. liquid_renewable = false,
  75. liquid_range = 0,
  76. liquid_viscosity = 0,
  77. use_texture_alpha = "blend",
  78. paramtype = "light",
  79. walkable = false,
  80. pointable = false,
  81. diggable = false,
  82. buildable_to = true,
  83. is_ground_content = false,
  84. post_effect_color = {a = 64, r = 0, g = 0, b = 200},
  85. sounds = {
  86. footstep = { name = "soundstuff_mono", gain = 1.0 },
  87. }
  88. })
  89. minetest.register_node("soundstuff:footstep_climbable", {
  90. description = "Climbable Footstep Sound Node".."\n"..
  91. "Plays sound when moving inside it; can climb up and down here",
  92. drawtype = "allfaces",
  93. tiles = {
  94. "soundstuff_node_climbable.png",
  95. },
  96. paramtype = "light",
  97. sunlight_propagates = true,
  98. walkable = false,
  99. climbable = true,
  100. is_ground_content = false,
  101. groups = { dig_immediate = 2 },
  102. sounds = {
  103. footstep = { name = "soundstuff_mono", gain = 1.0 },
  104. }
  105. })
  106. minetest.register_craftitem("soundstuff:eat", {
  107. description = "Eat Sound Item".."\n"..
  108. "Makes a sound when 'eaten' (with punch key)",
  109. inventory_image = "soundstuff_eat.png",
  110. on_use = minetest.item_eat(0),
  111. sound = {
  112. eat = { name = "soundstuff_mono", gain = 1.0 },
  113. }
  114. })
  115. minetest.register_tool("soundstuff:breaks", {
  116. description = "Break Sound Tool".."\n"..
  117. "Digs cracky=3 and more".."\n"..
  118. "Makes a sound when it breaks",
  119. inventory_image = "soundstuff_node_dug.png",
  120. sound = {
  121. breaks = { name = "soundstuff_mono", gain = 1.0 },
  122. },
  123. tool_capabilities = {
  124. max_drop_level=0,
  125. groupcaps={
  126. cracky={times={[2]=2.00, [3]=1.20}, uses=1, maxlevel=0},
  127. choppy={times={[2]=2.00, [3]=1.20}, uses=1, maxlevel=0},
  128. snappy={times={[2]=2.00, [3]=1.20}, uses=1, maxlevel=0},
  129. crumbly={times={[2]=2.00, [3]=1.20}, uses=1, maxlevel=0},
  130. },
  131. },
  132. })
  133. minetest.register_tool("soundstuff:punch_use", {
  134. description = "Punch Use Sound Tool\n"..
  135. "Digs cracky=3 and more\n"..
  136. "Makes a sound when used on node or entity",
  137. inventory_image = "soundstuff_node_dig.png",
  138. sound = {
  139. punch_use = { name = "soundstuff_mono", gain = 1.0 },
  140. },
  141. tool_capabilities = {
  142. max_drop_level=0,
  143. groupcaps={
  144. cracky={times={[2]=2.00, [3]=1.20}, uses=0, maxlevel=0},
  145. choppy={times={[2]=2.00, [3]=1.20}, uses=0, maxlevel=0},
  146. snappy={times={[2]=2.00, [3]=1.20}, uses=0, maxlevel=0},
  147. crumbly={times={[2]=2.00, [3]=1.20}, uses=0, maxlevel=0},
  148. },
  149. },
  150. })
  151. minetest.register_tool("soundstuff:punch_use_air", {
  152. description = "Punch Use (Air) Sound Tool\n"..
  153. "Makes a sound when used pointing at nothing",
  154. inventory_image = "soundstuff_node_dig.png",
  155. sound = {
  156. punch_use_air = { name = "soundstuff_mono", gain = 1.0 },
  157. },
  158. })
  159. -- Plays sound repeatedly
  160. minetest.register_node("soundstuff:positional", {
  161. description = "Positional Sound Node".."\n"..
  162. "Repeatedly plays a sound at the node location",
  163. on_construct = function(pos)
  164. local timer = minetest.get_node_timer(pos)
  165. timer:start(0)
  166. end,
  167. on_timer = function(pos, elapsed)
  168. local node = minetest.get_node(pos)
  169. local dist = node.param2
  170. if dist == 0 then
  171. dist = nil
  172. end
  173. minetest.sound_play("soundstuff_mono", { pos = pos, max_hear_distance = dist })
  174. local timer = minetest.get_node_timer(pos)
  175. timer:start(0.7)
  176. end,
  177. on_rightclick = function(pos, node, clicker)
  178. node.param2 = (node.param2 + 1) % 64
  179. minetest.set_node(pos, node)
  180. if clicker and clicker:is_player() then
  181. local dist = node.param2
  182. local diststr
  183. if dist == 0 then
  184. diststr = "<default>"
  185. else
  186. diststr = tostring(dist)
  187. end
  188. minetest.chat_send_player(clicker:get_player_name(), "max_hear_distance = " .. diststr)
  189. end
  190. end,
  191. groups = { dig_immediate = 2 },
  192. tiles = { "soundstuff_node_sound.png" },
  193. })