How to make a cloud-with-trigger not stack sounds

Place to get help with not working mods / modding interface.
User avatar
Reika
Filter Inserter
Filter Inserter
Posts: 587
Joined: Tue May 19, 2015 1:56 am
Contact:

How to make a cloud-with-trigger not stack sounds

Post by Reika »

Specifically a "smoke-with-trigger" that has one of its effects be "play-sound".

The problem is, setting the action_cooldown prevents the sound from playing until it has elapsed (ie it does not play on the first tick), and so if the lifetime of the smoke entity is less than that time, it never plays the sound. Additionally, this fails when there are multiple effects, some of which are supposed to be fired rapidly.

The code I am attempting to use is as follows:

Code: Select all

    action =
    {
      type = "direct",
      action_delivery =
      {
        type = "instant",
        target_effects =
        {
          type = "nested-result",
          action =
          {
            type = "area",
            radius = size,
            entity_flags = {"breaths-air"},
            action_delivery =
            {
              type = "instant",
              target_effects =
			  {
				  {
					type = "damage",
					damage = { amount = damage, type = "poison"}
				  },
				  {
					type = "play-sound",
					sound = {
						filename = "__NauvisDay__/sound/gasp.ogg",
						aggregation =
						{
							max_count = 1,
							remove = false
						},
					},
					action_cooldown = 4*60
				  }
			  }
            }
          }
        }
      }
    },
    action_cooldown = 10
It runs and plays the sound and deals the damage, but the sound is re-played every 10 ticks, which is a problem.
Image
Bilka
Factorio Staff
Factorio Staff
Posts: 3470
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: How to make a cloud-with-trigger not stack sounds

Post by Bilka »

You could try setting https://wiki.factorio.com/Types/Trigger ... peat_count, but I kind of doubt that it will help since it already defaults to 1.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
posila
Former Staff
Former Staff
Posts: 5448
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: How to make a cloud-with-trigger not stack sounds

Post by posila »

Try to set

Code: Select all

aggregation =
{
   max_count = 1,
   
   -- if false (default), max_count limits only number on instances that can be started at the same tick
   count_already_playing = true, 
   
   -- from interval 0.0 to 1.0 (default 1.0); how much of the sound should be played before it shouldn't be counted towards max_count anymore
   progress_threshold = 1.0, 
   
   -- if true, new instances of the sound are not created if max_count was reached;
   -- if false, volume of the new instances of the sound is decresed by multiplying it by count^(-0.45)
   remove = false 
}
User avatar
Reika
Filter Inserter
Filter Inserter
Posts: 587
Joined: Tue May 19, 2015 1:56 am
Contact:

Re: How to make a cloud-with-trigger not stack sounds

Post by Reika »

posila wrote:Try to set

Code: Select all

aggregation =
{
   max_count = 1,
   
   -- if false (default), max_count limits only number on instances that can be started at the same tick
   count_already_playing = true, 
   
   -- from interval 0.0 to 1.0 (default 1.0); how much of the sound should be played before it shouldn't be counted towards max_count anymore
   progress_threshold = 1.0, 
   
   -- if true, new instances of the sound are not created if max_count was reached;
   -- if false, volume of the new instances of the sound is decresed by multiplying it by count^(-0.45)
   remove = false 
}
It does not appear to work (ie the sound still stacks) with this code:

Code: Select all

              target_effects =
			  {
				  {
					type = "damage",
					damage = { amount = damage, type = "poison"}
				  },
				  {
					type = "play-sound",
					sound = {
						filename = "__NauvisDay__/sound/gasp.ogg",
						aggregation =
						{
						   max_count = 1,
						   
						   -- if false (default), max_count limits only number on instances that can be started at the same tick
						   count_already_playing = true,
						   
						   -- from interval 0.0 to 1.0 (default 1.0); how much of the sound should be played before it shouldn't be counted towards max_count anymore
						   progress_threshold = 1.0,
						   
						   -- if true, new instances of the sound are not created if max_count was reached;
						   -- if false, volume of the new instances of the sound is decresed by multiplying it by count^(-0.45)
						   remove = true
						}
					},
					action_cooldown = 4*60
				  }
			  }
Image
posila
Former Staff
Former Staff
Posts: 5448
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: How to make a cloud-with-trigger not stack sounds

Post by posila »

It looks like "aggregation" is loaded only when variations are present.

So it should be

Code: Select all

sound = {
  aggregation = {
    max_count = 1,
    count_already_playing = true,
    progress_threshold = 1.0,
    remove = true
  },
  variations = {
    {  filename = "__NauvisDay__/sound/gasp.ogg" }
  }
}
I'll change the loading, so it is more sane.
User avatar
Reika
Filter Inserter
Filter Inserter
Posts: 587
Joined: Tue May 19, 2015 1:56 am
Contact:

Re: How to make a cloud-with-trigger not stack sounds

Post by Reika »

posila wrote: Sun Aug 26, 2018 4:07 pm It looks like "aggregation" is loaded only when variations are present.

So it should be

Code: Select all

sound = {
  aggregation = {
    max_count = 1,
    count_already_playing = true,
    progress_threshold = 1.0,
    remove = true
  },
  variations = {
    {  filename = "__NauvisDay__/sound/gasp.ogg" }
  }
}
I'll change the loading, so it is more sane.
I never got a notification on this, so the update is delayed. The above suggested code does not work either - the sound is still stacked.
Image
Post Reply

Return to “Modding help”