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. Ifbodyis an Entity, the ears will track the position of the entity's Body. Ifbodyis a Vector, the ears will be fixed at that position. -
audience(Entity, Symbol or Flag): If provided, sets the ear position only for the specified audience. Defaults toowner. See Audience. -
owner(Entity): The player or team who owns theEars. Only used to interpret theaudienceparameter. -
priority(Number): Only theEarswith the highest priority will be used. Must be an integer between-128and127. Defaults to0.
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, seek?=, volume?, [body?, audience?, owner?])
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 from0to1. Defaults to1. -
audience(Entity, Symbol or Flag): If provided, only the specified audience will hear the sound. Defaults toAudience:All. See Audience. -
owner(Entity): The player or team who owns the sound. Only used to interpret theaudienceparameter.
Music
this.Music(music, loop?=, 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. -
loop(Boolean): if truthy, every time when the music reaches the end, it will start over from the beginning again. Defaults tofalse. -
volume(Number): the volume at which to play the music. Defaults to0.5. -
audience(Entity, Symbol or Flag): If provided, only the specified audience will hear the sound. Defaults toowner. See Audience. -
owner(Entity): The player who owns the sound. Only used to interpret theaudienceparameter. -
priority(Number): if the same player has multipleMusicbehaviors, only the one with the highest priority will be active. Must be an integer between-128and127(inclusive). Defaults to0.
delete this.Music
Stops this entity from playing background music.
Sing
this.Sing<Id = auto>(sound, seek?=, volume?, [body?, audience?, owner?])
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. Whenthisdespawns, the sound stops. -
Id: A unique identifier for the sound. If a sound already exists onthiswith the sameId, 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. -
seek(Number): The position within the sound to start playing from. Defaults to0s. -
volume(Number): The volume of the sound, a proportion from0to1. Defaults to1. -
audience(Entity, Symbol or Flag): If provided, only the specified audience will hear the sound. See Audience. -
owner(Entity): The player who owns the sound. Only used to interpret theaudienceparameter.
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 inemunits.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) or1(on). These are the only valid values. Any other nonzeroNumbervalue will be interpreted as1. Additionally,truewill be interpreted as1andfalsewill be interpreted as0.
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.