Types/Sound: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
(added some more properties)
(Updated styling of prototype doc migration note)
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<div class="stub"><p>'''The prototype docs have moved to a new website with an improved format.''' This documentation page can now be found here: [https://lua-api.factorio.com/latest/types/Sound.html https://lua-api.factorio.com/latest/types/Sound.html]
</p><p>This wiki page is no longer updated and '''will be removed at some point in the future''', so please update your browser bookmarks or other links that sent you here. If you'd like to contribute to the new docs, you can leave your feedback [https://forums.factorio.com/viewforum.php?f=233 on the forums].</p></div>
==Basics==
==Basics==
This type is used to produce sound from in-game entities, ambient sound, and music.
This type is either a table with the properties listed in [[#Optional properties]], or an array of tables with the following members:
== Mandatory properties ==
* filename - [[Types/FileName]] - Mandatory. Supported sound file formats are <code>.ogg</code>, <code>.wav</code> and <code>.voc</code>.
===filename===
* volume - [[Types/float]] - Optional. - Default: 1.0
* preload - [[Types/bool]] - Optional.
* speed - [[Types/float]] - Optional. - Default: 1.0 - Speed must be >= 1 / 64. This sets both min and max speed.
* min_speed - [[Types/float]] - Optional. Not loaded if speed is present. - Default: 1.0 - Speed must be >= 1 / 64.
* max_speed - [[Types/float]] - Mandatory if min_speed is present, otherwise not loaded. - Default: 1.0 - Must be >= min_speed.
 
== Optional properties ==
=== aggregation ===
'''Type''': [[Types/table]]
 
Table with the following members:
* max_count - [[Types/uint32]] - Mandatory.
* progress_threshold - [[Types/float]] - Optional. - Default: 1.0 - If count already playing is true, this will determine maximum progress when instance is counted toward playing sounds.
* remove - [[Types/bool]] - Mandatory.
* count_already_playing - [[Types/bool]] - Optional. - Default: false - If true already playing sounds are taken into account when checking maxCount.
 
=== allow_random_repeat ===
'''Type''': [[Types/bool]]
 
'''Default''': false
 
=== audible_distance_modifier ===
'''Type''': [[Types/double]]
 
'''Default''': 1.0
 
Modifies how far a sound can be heard. Must be between 0 and 1 (inclusive).
 
=== variations ===
'''Type''': [[Types/table]] (array) of [[Types/table]]s
 
Array of tables with the following members:
* filename - [[Types/FileName]] - Mandatory.
* volume - [[Types/float]] - Optional. - Default: 1.0
* preload - [[Types/bool]] - Optional.
* speed - [[Types/float]] - Optional. - Default: 1.0 - Speed must be >= 1 / 64. This sets both min and max speed.
* min_speed - [[Types/float]] - Optional. Not loaded if speed is present. - Default: 1.0 - Speed must be >= 1 / 64.
* max_speed - [[Types/float]] - Mandatory if min_speed is present, otherwise not loaded. - Default: 1.0 - Must be >= min_speed.
 
=== filename ===
'''Type''': [[Types/FileName]]
'''Type''': [[Types/FileName]]


Used to let the game know what audio file you want it to use.
Mandatory if <code>variations</code> is not given.
===sound===
 
'''Type''': ???
Support sound file formats are <code>.ogg</code>, <code>.wav</code> and <code>.voc</code>.
 
=== volume ===
'''Type''': [[Types/float]]
 
'''Default''': 1.0
 
Only loaded if <code>variations</code> is not given.
 
=== preload ===
'''Type''': [[Types/bool]]


Can be used instead of "filename".
Only loaded if <code>variations</code> is not given.


Example:
=== speed ===
    "sound": {"filename": "__base__/sound/substation.ogg"},
'''Type''': [[Types/float]]


===volume===
'''Default''': 1.0
'''Type''': [[Types/unsigned]]


Decides how loud the audio is.
Only loaded if <code>variations</code> is not given. Speed must be >= 1 / 64. This sets both min and max speed.
=== apparent_volume ===
 
'''Type''': [[Types/double]]
=== min_speed ===
'''Type''': [[Types/float]]
 
'''Default''': 1.0


Can be used instead of "volume".
Only loaded if <code>variations</code> is not given. Not loaded if speed is present. Speed must be >= 1 / 64.
== Optional properties ==
=== audible_distance_modifier ===
'''Type''': [[Types/double]]


Modifies how far a sound can be heard. Default is ? which means that the sound can be heard up to ? tiles away from the entity.
=== max_speed ===
=== probability ===
'''Type''': [[Types/float]]
'''Type''': [[Types/double]]


Modifies how often the sound is played.
'''Default''': 1.0


Only loaded if <code>variations</code> is not given. Mandatory if min_speed is present, otherwise not loaded. Must be >= min_speed.


==Example==
==Example==
Line 38: Line 92:
       volume = 1.2
       volume = 1.2
     }
     }
{{Prototype property type usage|{{FULLPAGENAME}}}}

Revision as of 10:42, 21 September 2023

The prototype docs have moved to a new website with an improved format. This documentation page can now be found here: https://lua-api.factorio.com/latest/types/Sound.html

This wiki page is no longer updated and will be removed at some point in the future, so please update your browser bookmarks or other links that sent you here. If you'd like to contribute to the new docs, you can leave your feedback on the forums.


Basics

This type is either a table with the properties listed in #Optional properties, or an array of tables with the following members:

  • filename - Types/FileName - Mandatory. Supported sound file formats are .ogg, .wav and .voc.
  • volume - Types/float - Optional. - Default: 1.0
  • preload - Types/bool - Optional.
  • speed - Types/float - Optional. - Default: 1.0 - Speed must be >= 1 / 64. This sets both min and max speed.
  • min_speed - Types/float - Optional. Not loaded if speed is present. - Default: 1.0 - Speed must be >= 1 / 64.
  • max_speed - Types/float - Mandatory if min_speed is present, otherwise not loaded. - Default: 1.0 - Must be >= min_speed.

Optional properties

aggregation

Type: Types/table

Table with the following members:

  • max_count - Types/uint32 - Mandatory.
  • progress_threshold - Types/float - Optional. - Default: 1.0 - If count already playing is true, this will determine maximum progress when instance is counted toward playing sounds.
  • remove - Types/bool - Mandatory.
  • count_already_playing - Types/bool - Optional. - Default: false - If true already playing sounds are taken into account when checking maxCount.

allow_random_repeat

Type: Types/bool

Default: false

audible_distance_modifier

Type: Types/double

Default: 1.0

Modifies how far a sound can be heard. Must be between 0 and 1 (inclusive).

variations

Type: Types/table (array) of Types/tables

Array of tables with the following members:

  • filename - Types/FileName - Mandatory.
  • volume - Types/float - Optional. - Default: 1.0
  • preload - Types/bool - Optional.
  • speed - Types/float - Optional. - Default: 1.0 - Speed must be >= 1 / 64. This sets both min and max speed.
  • min_speed - Types/float - Optional. Not loaded if speed is present. - Default: 1.0 - Speed must be >= 1 / 64.
  • max_speed - Types/float - Mandatory if min_speed is present, otherwise not loaded. - Default: 1.0 - Must be >= min_speed.

filename

Type: Types/FileName

Mandatory if variations is not given.

Support sound file formats are .ogg, .wav and .voc.

volume

Type: Types/float

Default: 1.0

Only loaded if variations is not given.

preload

Type: Types/bool

Only loaded if variations is not given.

speed

Type: Types/float

Default: 1.0

Only loaded if variations is not given. Speed must be >= 1 / 64. This sets both min and max speed.

min_speed

Type: Types/float

Default: 1.0

Only loaded if variations is not given. Not loaded if speed is present. Speed must be >= 1 / 64.

max_speed

Type: Types/float

Default: 1.0

Only loaded if variations is not given. Mandatory if min_speed is present, otherwise not loaded. Must be >= min_speed.

Example

   {
     filename = "__base__/sound/ambient/world-ambience-3.ogg",
     volume = 1.2
   }

Template:Prototype property type usage