[Donion] [1.1.74] surface.play_sound override_sound_type has no effect
Posted: Sun Jan 08, 2023 12:49 am
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:
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.
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"}
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.