Skip to content

Core - Sounds Module

anvil.api.core.sounds

MusicDefinition

Bases: AddonObject

Singleton for handling music definitions.

Attributes:

Name Type Description
_extensions dict

The file extensions for the music definition.

_sounds list[_SoundDescription]

A list of sound descriptions. Defaults to empty list.

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

content(content)

Sets the content of the addon object and returns the object.

Parameters:

Name Type Description Default
content any

The content to be set for the addon object.

required

Returns:

Name Type Description
self AddonObject

The instance of the current AddonObject.

music_definition(music_reference, min_delay=60, max_delay=180)

Defines a music for the MusicDefinition instance.

Parameters:

Name Type Description Default
music_category MusicCategory

The category of the music.

required
min_delay int

The minimum delay for the music. Defaults to 60.

60
max_delay int

The maximum delay for the music. Defaults to 180.

180

Returns:

Name Type Description
_SoundDescription

The created sound description instance.

queue()

Returns the queue for the music definition.

Returns:

Name Type Description
queue

The queue for the music definition.

set_identifier_data(data)

Sets the data of the addon object.

Parameters:

Name Type Description Default
data any

The data to be set for the addon object.

required

SoundDefinition

Bases: AddonObject

Singleton for handling sound definitions.

Attributes:

Name Type Description
_sounds list[_SoundDescription]

A list of sound descriptions. Defaults to empty list.

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

content(content)

Sets the content of the addon object and returns the object.

Parameters:

Name Type Description Default
content any

The content to be set for the addon object.

required

Returns:

Name Type Description
self AddonObject

The instance of the current AddonObject.

queue()

Returns the queue for the sound definition.

Returns:

Name Type Description
queue

The queue for the sound definition.

set_identifier_data(data)

Sets the data of the addon object.

Parameters:

Name Type Description Default
data any

The data to be set for the addon object.

required

sound_reference(sound_reference, category, use_legacy_max_distance=False, max_distance=0, min_distance=9999)

Defines a sound for the SoundDefinition instance.

Parameters:

Name Type Description Default
sound_reference str

The sound_reference of the sound.

required
category SoundCategory

The category of the sound.

required
use_legacy_max_distance bool

Use legacy max distance if True. Defaults to False.

False
max_distance int

The maximum distance for the sound. Defaults to 0.

0
min_distance int

The minimum distance for the sound. Defaults to 9999.

9999

Returns:

Name Type Description
_SoundDescription

The created sound description instance.

SoundEvent

Bases: AddonObject

Singleton for handling sound events for entities and individual sounds.

Manages the creation and configuration of sound events that can be triggered by entities or as standalone sounds in the game.

identifier property

Returns the identifier of the addon object in the format 'namespace:name'.

Returns:

Name Type Description
str Identifier

The identifier of the addon object.

name property

Returns the name of the addon object.

Returns:

Name Type Description
str str

The name of the addon object.

content(content)

Sets the content of the addon object and returns the object.

Parameters:

Name Type Description Default
content any

The content to be set for the addon object.

required

Returns:

Name Type Description
self AddonObject

The instance of the current AddonObject.

set_identifier_data(data)

Sets the data of the addon object.

Parameters:

Name Type Description Default
data any

The data to be set for the addon object.

required