place-sounds/control.lua

changeset 12
2e09a72b2dfa
child 19
adbc5c74f279
equal deleted inserted replaced
11:da16c5a08162 12:2e09a72b2dfa
1 script.on_event(defines.events.on_built_entity, function(event)
2 local sound_path = "entity-close/"..event.entity.name
3 if helpers.is_valid_sound_path(sound_path)
4 then
5 event.entity.surface.play_sound{
6 path=sound_path,
7 position=game.players[event.player_index].position,
8 }
9 end
10 end)
11
12 script.on_event(defines.events.on_robot_built_entity, function(event)
13 local sound_path = "entity-close/"..event.entity.name
14 if helpers.is_valid_sound_path(sound_path)
15 then
16 event.entity.surface.play_sound{
17 path=sound_path,
18 position=event.entity.position,
19 }
20 end
21 end)
22
23 script.on_event(defines.events.on_player_mined_entity, function(event)
24 local sound_path = "entity-open/"..event.entity.name
25 if helpers.is_valid_sound_path(sound_path)
26 then
27 event.entity.surface.play_sound{
28 path=sound_path,
29 position=game.players[event.player_index].position,
30 }
31 end
32 end)
33
34 script.on_event(defines.events.on_robot_mined_entity, function(event)
35 local sound_path = "entity-open/"..event.entity.name
36 if helpers.is_valid_sound_path(sound_path)
37 then
38 event.entity.surface.play_sound{
39 path=sound_path,
40 position=event.entity.position,
41 }
42 end
43 end)

mercurial