Sound

class Sound(config: NativeObject)

Instances a new Sound with certain properties. These properties should be passed through as a normal JavaScript object.

REQUIRED:

  • source (String) - filename, relative to ChatTriggers assets directory

OPTIONAL:

  • priority (boolean) - whether this sound should be prioritized, defaults to false

  • loop (boolean) - whether to loop this sound over and over, defaults to false

  • stream (boolean) - whether to stream this sound rather than preload it (should be true for large files), defaults to false

CONFIGURABLE (can be set in config object, or changed later, but MAKE SURE THE WORLD HAS LOADED)

  • category (String) - which category this sound should be a part of, see setCategory.

  • volume (float) - volume of the sound, see setVolume

  • pitch (float) - pitch of the sound, see setPitch

  • x, y, z (float) - location of the sound, see setPosition. Defaults to the players position.

  • attenuation (int) - fade out model of the sound, see setAttenuation

Parameters

config

the JavaScript config object

Constructors

Link copied to clipboard
fun Sound(config: NativeObject)

Functions

Link copied to clipboard
fun getPitch(): Float
Link copied to clipboard
fun getVolume(): Float
Link copied to clipboard
fun onWorldLoad()
Link copied to clipboard
fun pause()

Pauses the sound, to be resumed later

Link copied to clipboard
fun play()

Plays/resumes the sound

Link copied to clipboard
fun rewind()

Immediately restarts the sound

Link copied to clipboard
fun setAttenuation(model: Int): Sound

Sets the attenuation (fade out over space) of the song. Models are: NONE(0) - no fade ROLLOFF(1) - this is the default, meant to be somewhat realistic LINEAR(2) - fades out linearly, as the name implies

Link copied to clipboard
fun setCategory(category: String): Sound

Sets the category of this sound, making it respect the Player's sound volume sliders. Options are: master, music, record, weather, block, hostile, neutral, player, and ambient

Link copied to clipboard
fun setPitch(pitch: Float): Sound

Sets this sound's pitch.

Link copied to clipboard
fun setPosition(x: Float, y: Float, z: Float): Sound

Updates the position of this sound

Link copied to clipboard
fun setVolume(volume: Float): Sound

Sets this sound's volume. Will override the category if called after setCategory, but not if called before.

Link copied to clipboard
fun stop()

Completely stops the sound

Properties

Link copied to clipboard
var isListening: Boolean = false

Sources

Link copied to clipboard