[Solved] How do I upload a sound to use when pressing a button?

Place to get help with not working mods / modding interface.
User avatar
yaim904
Fast Inserter
Fast Inserter
Posts: 129
Joined: Wed Nov 17, 2021 11:26 pm
Contact:

[Solved] How do I upload a sound to use when pressing a button?

Post by yaim904 »

Hello, today I wanted to use a sound that comes with Factorio, but it is not available for use in mods. So I am trying to load it myself and then call it.
It is not working for me.

Help

The following is the code I am using.

Code: Select all

    ---> data-final-fixes.lua <---
    data.raw["utility-sounds"]["default"]["gui_tool_click"] = {
        filename = "__core__/sound/gui-tool-button.ogg",
        aggregation = { max_count = 3, remove = true }
    }
    
    ---> control.lua <---
    Player.play_sound({ path = "utility/gui_tool_click" })
I'm using what I found in the documentation and some code from Factorio itself, but I must admit that I don't know what I'm doing.
Last edited by yaim904 on Mon Jul 28, 2025 10:33 pm, edited 1 time in total.
Solo entiendo español, pero si tu también lo entiendes, escríbeme
:D
Everything i write in English is translated by Deepl.
:D
Osmo
Fast Inserter
Fast Inserter
Posts: 108
Joined: Wed Oct 23, 2024 12:08 pm
Contact:

Re: How do I upload a sound to use when pressing a button?

Post by Osmo »

The UtilitySounds prototype only holds some predefined sounds. For custom sounds, you beed to define a Sound Protoype https://lua-api.factorio.com/latest/pro ... otype.html
User avatar
yaim904
Fast Inserter
Fast Inserter
Posts: 129
Joined: Wed Nov 17, 2021 11:26 pm
Contact:

Re: How do I upload a sound to use when pressing a button?

Post by yaim904 »

My solution

Code: Select all

---> data-final-fixes.lua <---
data:extend({{
    type = "sound",
    name = "gui_tool_button",
    filename = "__core__/sound/gui-tool-button.ogg"
}})

---> control.lua <---
Player.play_sound({ path = "gui_tool_button" })

Thanks for the message.
The truth is that I solved it on my own, but I forgot to upload it.

Anyway, thank you very much.
Osmo wrote: Thu Jul 24, 2025 10:47 am
Solo entiendo español, pero si tu también lo entiendes, escríbeme
:D
Everything i write in English is translated by Deepl.
:D
Post Reply

Return to “Modding help”