Page 1 of 1

Is it impossible to add new utility/sounds?

Posted: Sat Feb 17, 2018 5:49 pm
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?

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

Posted: Sat Feb 17, 2018 6:00 pm
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

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

Posted: Sat Feb 17, 2018 6:40 pm
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*.

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

Posted: Sat Feb 17, 2018 6:42 pm
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

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

Posted: Sat Feb 17, 2018 7:31 pm
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?