Page 1 of 1

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

Posted: Sat Aug 25, 2018 11:04 pm
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.

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

Posted: Sun Aug 26, 2018 6:26 am
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.

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

Posted: Sun Aug 26, 2018 7:19 am
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 
}

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

Posted: Sun Aug 26, 2018 3:57 pm
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
				  }
			  }

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

Posted: Sun Aug 26, 2018 4:07 pm
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.

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

Posted: Wed Oct 03, 2018 11:08 pm
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.