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