Skip to main content

Audio

Ears

this.Ears([body], priority?=, [audience?, owner?])
delete this.Ears

Determines the position of the ears for a given audience. Positional audio sources will sound louder when closer to the ears, and will be panned to the left or right speaker based on their relative position to the ears.

  • body (Entity or Vector): Determines the position. If body is an Entity, the ears will track the position of the entity's Body. If body is a Vector, the ears will be fixed at that position.

  • audience (Entity): If set to a player or team, only determines the position of the ears for that player or team. Otherwise, determines the ears for all players and spectators. Defaults to the value of owner.

  • owner (Entity): Only used as the default value for audience.

  • priority (Number): Only the Ears with the highest priority will be used. Must be an integer between -128 and 127. Defaults to 0.

FullscreenToggle

FullscreenToggle([ui=]) |use ui:whenFullscren, use ui:whenWindowed| { }

Creates an element in the user interface that allows the player to switch between fullscreen and windowed mode.

  • ui (UI): The slot in the user interface where the element will be inserted.

Subblock: The subblock will be called immediately to populate the element's content. It is optional as there are defaults for both fullscreen and windowed states. Use the %ui:whenFullscreen { ... } syntax to populate one of the slots, see UI for more information.

  • ui:whenFullscreen (UI): populate this slot with the content that should be displayed when fullscreen. If left empty, will display a default button that will exit fullscreen mode.
  • ui:whenWindowed (UI): populate this slot with the content that should be displayed when windowed. If left empty, will display a default button that will enter fullscreen mode.

Hear

Hear(sound, volume?=, [body?, audience?])

Plays a sound. The sound will always play to completion.

  • sound (Asset): The sound to play. Must refer to an audio asset file. Normally this would be specified with an @ string, for example @fireball.esfx.

  • body (Entity, Vector or Null): Designates the position which the sound is coming from. If this is an entity, the sound will be played from the position of the Entity's Body. If this is a Vector, the sound will be played from that game-world coordinate position. If null (the default), the sound will be played with no positional audio effects.

  • volume (Number): The volume of the sound, a proportion from 0 to 1. Defaults to 1.

  • audience (Entity): If set to a player or team, only that player or team can hear this sound.

Music

this.Music(music, volume?=, priority?, [audience?, owner?])

Plays background music.

Parameters:

  • this (Entity): defines the lifespan of this behavior.

  • music (Asset): determines which music file to play. Normally this would be specified with an @ string, for example @dynamite.mp3.

  • volume (Number): the volume at which to play the music. Defaults to 0.5.

  • audience (Entity): if set to a player or team Entity, the behavior will only apply to those players, rather than all players in the game. If undefined, defaults to the value of owner.

  • owner (Entity): only used as a default value for audience.

  • priority (Number): if the same player has multiple Music behaviors, only the one with the highest priority will be active. Must be an integer between -128 and 127 (inclusive). Defaults to 0.

delete this.Music

Stops this entity from playing background music.

Sing

this.Sing<Id = auto>(sound, volume?=, [body?, audience?])

Adds or replaces a component to the this Entity that plays a sound for as long as this continues to exist.

  • this (Entity): Defines the lifespan of the sound. When this despawns, the sound stops.

  • Id: A unique identifier for the sound. If a sound already exists on this with the same Id, the previous sound will be deleted.

  • sound (Asset): The sound to play. Must refer to an audio asset file. Normally this would be specified with an @ string, for example @fireball.esfx.

  • body (Entity, Vector or Null): Designates the position which the sound is coming from. If this is an entity, the sound will be played from the position of the Entity's Body. If this is a Vector, the sound will be played from that game-world coordinate position. If null (the default), the sound will be played with no positional audio effects.

  • volume (Number): The volume of the sound, a proportion from 0 to 1. Defaults to 1.

  • audience (Entity): If set to a player or team, only that player or team can hear this sound.

delete this.Sing<Id>

Removes a sound from the this Entity.

  • this: The Entity that the sound is attached to.
  • Id: The unique identifier of the sound to remove.

VolumeDropdown

VolumeDropdown(width?=, [ui])

Creates a volume editor dropdown in the user interface that allows the current player to change the volume of the game.

  • width (Number): the width of the volume editor in em units.
  • ui (UI): the slot in the user interface to insert the volume editor element.

VolumeIntent

VolumeIntent(volume) -> intent

Returns an intent to change the volume to a particular level. Attach the intent to a button Button to trigger it.

  • volume (Number): A value representing the volume level where 0 (off) or 1 (on). These are the only valid values. Any other nonzero Number value will be interpreted as 1. Additionally, true will be interpreted as 1 and false will be interpreted as 0.

VolumeToggle

VolumeToggle([ui=]) |use ui:whenOn, use ui:whenOff| { }

Creates an element in the user interface that allows the user to toggle the volume on and off.

  • ui (UI): The slot in the user interface where the element will be inserted.

Subblock: The subblock will be called immediately to populate the element's content. The subblock is optional as there are defaults for both the on and off states. Use the %ui:whenOn { ... } syntax to populate one of the slots, see UI for more information.

  • ui:whenOn (UI): populate this slot with the content that should be displayed when the volume is on. If left empty, will display a default button that will toggle the volume to off.
  • ui:whenOff (UI): populate this slot with the content that should be displayed when the volume is off. If left empty, will display a default button that will toggle the volume to on.