Prototype/Sound#aggregation Documentation

Place to get help with not working mods / modding interface.
User avatar
kizrak
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Thu Jul 19, 2018 1:27 am
Contact:

Prototype/Sound#aggregation Documentation

Post by kizrak »

I'm trying to find more detailed documentation/explanation of how to use Prototype/Sound#aggregation

Code: Select all

aggregation
Type: table
Table with the following members:

max_count - uint32 - Mandatory.
progress_threshold - float - Optional. - Default: 1.0 - If count already playing is true, this will determine maximum progress when instance is counted toward playing sounds.
remove - bool - Mandatory.
count_already_playing - bool - Optional. - Default: false - If true already playing sounds are taken into account when checking maxCount.
I assumed I could use this data structure to limit the number of simultaneous instance of this sound, but I've been unable to accomplish this so maybe it is used for something else that I cannot fathom. :?

Any help would be greatly appreciated! :D

Thanks,
-Kizrak
User avatar
Stargateur
Filter Inserter
Filter Inserter
Posts: 255
Joined: Sat Oct 05, 2019 6:17 am
Contact:

Re: Prototype/Sound#aggregation Documentation

Post by Stargateur »

https://lua-api.factorio.com/latest/pro ... ggregation

Code: Select all

aggregation = {
  max_count = 1,
  remove = true,
  count_already_playing = true,
},
Thus I don't see much why `count_already_playing` even exist, what does it count if not already playing sound ???

If I understand all correctly aggregation is not used when you use api such as play_sound in control.lua. It's must be used by the game for build-in sound like https://lua-api.factorio.com/latest/pro ... ying_sound. So you must code yourself the logic in control.lua to avoid your sound to be played twice.

That would be great if play_sound take into account aggregate value too.
Donion
Factorio Staff
Factorio Staff
Posts: 391
Joined: Sun Aug 22, 2021 9:18 am
Contact:

Re: Prototype/Sound#aggregation Documentation

Post by Donion »

Stargateur wrote: Tue Jun 03, 2025 6:31 pm Thus I don't see much why `count_already_playing` even exist, what does it count if not already playing sound ???
If count_already_playing is false the aggregation is applied only on new instances of the sound set to be played on a given tick.
Stargateur wrote: Tue Jun 03, 2025 6:31 pm That would be great if play_sound take into account aggregate value too.
They do take the aggregation specification into account. With the caveat that the position needs to be specified. If no position is given, the sounds are played globally and global sounds are not aggregated.
Post Reply

Return to “Modding help”