# HG changeset patch # User Teemu Piippo # Date 1751489612 -10800 # Node ID 2e09a72b2dfa070fb49b4f1f1da624060a883db0 # Parent da16c5a081629b826f53daea0228fc7c13f2fc76 Added a mod that plays placement sounds diff -r da16c5a08162 -r 2e09a72b2dfa place-sounds/control.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/place-sounds/control.lua Wed Jul 02 23:53:32 2025 +0300 @@ -0,0 +1,43 @@ +script.on_event(defines.events.on_built_entity, function(event) + local sound_path = "entity-close/"..event.entity.name + if helpers.is_valid_sound_path(sound_path) + then + event.entity.surface.play_sound{ + path=sound_path, + position=game.players[event.player_index].position, + } + end +end) + +script.on_event(defines.events.on_robot_built_entity, function(event) + local sound_path = "entity-close/"..event.entity.name + if helpers.is_valid_sound_path(sound_path) + then + event.entity.surface.play_sound{ + path=sound_path, + position=event.entity.position, + } + end +end) + +script.on_event(defines.events.on_player_mined_entity, function(event) + local sound_path = "entity-open/"..event.entity.name + if helpers.is_valid_sound_path(sound_path) + then + event.entity.surface.play_sound{ + path=sound_path, + position=game.players[event.player_index].position, + } + end +end) + +script.on_event(defines.events.on_robot_mined_entity, function(event) + local sound_path = "entity-open/"..event.entity.name + if helpers.is_valid_sound_path(sound_path) + then + event.entity.surface.play_sound{ + path=sound_path, + position=event.entity.position, + } + end +end) diff -r da16c5a08162 -r 2e09a72b2dfa place-sounds/data-final-fixes.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/place-sounds/data-final-fixes.lua Wed Jul 02 23:53:32 2025 +0300 @@ -0,0 +1,18 @@ +---@class entity EntityPrototype +---@class item ItemPrototype +local function copy_item_sounds_to_entity(item, entity) + entity.open_sound = table.deepcopy(item.pick_sound) + entity.close_sound = table.deepcopy(item.drop_sound) +end + +-- prevent metallic machine sounds when placing power poles +local sounds = require("__base__.prototypes.entity.sounds") +for _, electric_pole in pairs(data.raw["electric-pole"]) +do + electric_pole.open_sound = sounds.electric_large_open + electric_pole.close_sound = sounds.electric_large_close +end + +-- prevent metallic machine sounds when placing stuff made of bricks +copy_item_sounds_to_entity(data.raw.item["stone-furnace"], data.raw.furnace["stone-furnace"]) +copy_item_sounds_to_entity(data.raw.item["stone-wall"], data.raw.wall["stone-wall"]) diff -r da16c5a08162 -r 2e09a72b2dfa place-sounds/info.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/place-sounds/info.json Wed Jul 02 23:53:32 2025 +0300 @@ -0,0 +1,9 @@ +{ + "author": "teemu", + "dependencies": ["base"], + "description": "Building and mining structures plays their open and closed sounds.", + "factorio_version": "2.0", + "name": "place-sounds", + "title": "Play sounds when placed", + "version": "1.0.0" +} \ No newline at end of file