Is it impossible to add new utility/sounds?

Place to get help with not working mods / modding interface.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Is it impossible to add new utility/sounds?

Post by eradicator »

OK. So this is really weird and i'm 90% sure this has to be some kind of freak bug.
I'm trying to add a new utility sound to use with surface.play_sound(). But all attempts at this have failed so far.

For adding the prototype i vertabitm copied the function body from /core/prototypes/utility-sounds.lua

Code: Select all

data.raw["utility-sounds"]["default"]['warp'] =
  {
    {
      filename = '__er-waypoints__/assets/warp.ogg'
    }
  }
This raises no errors during startup so it looks like it works fine... (I've added print() to see that the file is really actually loaded, and i've even tried to add both the .ogg file and the code directly to /core/protoypes/ulitity-sounds.lua. I've used serpent.block() to check that the table looks exactly like every other table in utility-sounds...

But:

Every time i try to use the sound with surface.play_sounds() i get an <Unknown utility sound "warp"> error.

Code: Select all

  wp.entity.surface.play_sound{
    -- path = 'utility/axe_mining_ore',
    path = 'utility/warp',
    -- path = "entity-build/wooden-chest"
    position = wp.entity.position,
    volume_modifier = 0.8,
    }
It works fine with other utility sounds i've tried. And warp.ogg plays fine if i use it as a click sound in a button style. So. Like...WTF is wrong with this.

Any help would be greatly appreciated. Has anyone else successfully added new utility sounds?
Bilka
Factorio Staff
Factorio Staff
Posts: 3470
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Is it impossible to add new utility/sounds?

Post by Bilka »

That's not how you add sounds for usage as a SoundPath :P Here is how you do that: https://github.com/Bilka2/Portals/blob/ ... sounds.lua
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Is it impossible to add new utility/sounds?

Post by eradicator »

That...does indeed work. But i'm still in WTH mode. The base game doesn't use type = "sound" anywhere and the api doc does not mention typeless sounds either. And i mean...i literally added code to the core files and it didn't have any effect. Something smells like fishy there.

Thanks for the quick help though. Also apparently players can't hear sounds that are created while they're out of range.... *sigh*.
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5412
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Is it impossible to add new utility/sounds?

Post by Klonan »

Utility sounds are hardcoded in the CPP and bound to specific Lua definitions, so we can call them from within the engine very easily
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Is it impossible to add new utility/sounds?

Post by eradicator »

Klonan wrote:Utility sounds are hardcoded in the CPP and bound to specific Lua definitions, so we can call them from within the engine very easily
Thanks for confirming my suspicions on that! At least now i can sleep properly tonight ;). Would you mind adding a comment to utility-sounds.lua to explain that they can't be added by mods?
Post Reply

Return to “Modding help”