Page 1 of 1

What's wrong with my attempt to overwrite the attack sound?

Posted: Thu Jan 30, 2020 9:06 pm
by Begovere
I'm currently trying to create a mod that allows the user to overwrite the sound that's played when friendly structures are attacked by biters. My mod folder currently contains a folder named "sound" with the new soundfile named "alert-destroyed.ogg" and my data-updates.lua currently looks like this:

Code: Select all

data:extend(
{
  ["utility-sounds"] = {
    default = {
      alert_destroyed = {
        {
          filename = "__CustomAttackSound__/sound/alert-destroyed.ogg"
        }
      }
    }
  }
})
When starting the game, I get this error message: Image

Can you please help me and tell me what I'm doing wrong and what I need to fix?

Re: What's wrong with my attempt to overwrite the attack sound?

Posted: Fri Jan 31, 2020 12:12 am
by asdff45
You are trying to create a new prototype with data:extend.
What you want to do, is override it. That is possible, by editing the data.raw table. https://wiki.factorio.com/Data.raw

So, in your case:

Code: Select all

data.raw["utility-sounds"].default.alert_destroyed = {
    filename = "__CustomAttackSound__/sound/alert-destroyed.ogg"
}

Re: What's wrong with my attempt to overwrite the attack sound?

Posted: Fri Jan 31, 2020 11:09 am
by Begovere
Thank you for the helpful advice, it fixed my problem and it works now. :D