Page 1 of 1

[Donion] [1.1.74] surface.play_sound override_sound_type has no effect

Posted: Sun Jan 08, 2023 12:49 am
by Deadlock989
While trying to get to the bottom of this random missing sound problem, I noticed the documentation for SoundType suggests that "some sound types are mixed differently than others, e.g. zoom level effects are applied" and wondered if that was causing my issues. So I experimented with setting sound types in the override_sound_type property of surface.play_sound(), with the debug menu "show-recently-played-sound-info" setting on.

It seems that the override_sound_type property has no effect at all. If you set it to a garbage value (not a member of the SoundType union), the game halts with a script error, detecting the illegal value. But otherwise, the sounds produced are always of the type specified in the sound prototype ("game-effect" by default).

To reproduce, set all of your volume sliders except Master and Game effects to zero, turn on the recently played sound info F4 debug setting, and try the following:

Code: Select all

/c game.player.surface.play_sound{path="utility/build_small",position=game.player.position,override_sound_type="game-effect"}
/c game.player.surface.play_sound{path="utility/build_small",position=game.player.position,override_sound_type="environment"}
/c game.player.surface.play_sound{path="utility/build_small",position=game.player.position,override_sound_type="alert"}
You will hear all three even though Environment and Alert have been muted and the debug info will show "game-effect" each time.

Edited to add, this seems to be the case for both LuaSurface.play_sound() and LuaPlayer.play_sound(), and for sounds of both types utility-sounds and sound.

Re: [Donion] [1.1.74] surface.play_sound override_sound_type has no effect

Posted: Wed Jan 11, 2023 10:54 am
by Donion
Thank you for the report. I've fumbled this with the SDL backend. It's now fixed for the next release.

Also, the recently-played-sound-info now shows the overridden type, although note that the entries in the list linger for 3s after the sound stops playing and if you play the same sound again within that time with a different override sound type, it will keep showing the previous one.

Re: [Donion] [1.1.74] surface.play_sound override_sound_type has no effect

Posted: Wed Jan 11, 2023 6:56 pm
by Deadlock989
Thanks for this.