CorsixTH Lua Documentation

Audio Class

Layer which handles the Lua-facing side of loading and playing audio.

Declared on: line 29 of Lua/audio.lua.

Method Index

Member Index

function Audio:Audio(app)

Parameters:

NameTypeDescription
app ? ?

Declared on: line 35 of Lua/audio.lua.

function Audio:cacheSoundFilenamesAssociatedWithName(name)

Parameters:

NameTypeDescription
name ? ?

Declared on: line 403 of Lua/audio.lua.

function Audio:dumpSoundArchive(out_dir)

Parameters:

NameTypeDescription
out_dir ? ?

Declared on: line 292 of Lua/audio.lua.

function Audio:entityNoLongerWaitingForSoundsToBeTurnedOn(entity)

Parameters:

NameTypeDescription
entity ? ?

Declared on: line 819 of Lua/audio.lua.

function Audio:entitySoundsHandler(sounds, entity, silences, silences_pointer)

Called by the above function. This function's integer array parameters for the min and max silence lengths should provide lengths for this game's different speeds, indexed as follows: [1] Slowest [2] Slow [3] Normal [4] Fast [5] Maximum Speed

Parameters:

NameTypeDescription
sounds string A name pattern for the sequence of related sounds to be played for example: LAVA00*.wav
entity ? : Where the sounds will be played at, the player won't hear the sounds being played at the entity when it isn't in their view.
silences integer or array the different pause durations to be used between the played sounds.
silences_pointer integer the index for the pause duration which should be used after this call's sound has been played. --

Declared on: line 482 of Lua/audio.lua.

function Audio:getFileData(index)

Parameters:

NameTypeDescription
index ? ?

Declared on: line 681 of Lua/audio.lua.

function Audio:initSpeech(speech_file)

Parameters:

NameTypeDescription
speech_file ? ?

Declared on: line 227 of Lua/audio.lua.

function Audio:isPlaying(sound)

Determine if a given sound is still playing

Parameters:

NameTypeDescription
sound table The `sound` table returned by `Audio:playSound`.

Declared on: line 389 of Lua/audio.lua.

function Audio:notifyJukebox()

search for jukebox and notify it to update its play button

Declared on: line 827 of Lua/audio.lua.

function Audio:onSoundPlayed(played_callbacks_id)

Parameters:

NameTypeDescription
played_callbacks_id ? ?

Declared on: line 533 of Lua/audio.lua.

function Audio:pauseBackgroundTrack()

Returns whether music is currently paused or not after the call.

If nil is returned music might either be playing or completely stopped.

Declared on: line 615 of Lua/audio.lua.

function Audio:playBackgroundTrack(index)

Plays a given background track.

Playback will only start if the configuration says it's ok. (play_music = true)

Parameters:

NameTypeDescription
index ? Index of the track to play in the playlist.

Declared on: line 696 of Lua/audio.lua.

function Audio:playEntitySounds(names, entity, min_silence_lengths, max_silence_lengths, num_silences)

Plays related sounds at an entity in a random sequence, with random length silences between the sounds. This function's integer array parameters for the min and max silence lengths should provide lengths for this game's different speeds, indexed as follows: [1] Slowest [2] Slow [3] Normal [4] Fast [5] Maximum Speed

Parameters:

NameTypeDescription
names string A name pattern for the sequence of related sounds to be played for example: LAVA00*.wav
entity ? : Where the sounds will be played at, the player won't hear the sounds being played at the entity when it isn't in their view.
min_silence_lengths integer or array The desired minimum silence lengths for this game's different speeds.
max_silence_lengths integer or array The desired maximum silence lengths for this game's different speeds.
num_silences integer How many different silence lengths should be used, this can be a nil parameter. --

Declared on: line 456 of Lua/audio.lua.

function Audio:playNextOrPreviousBackgroundTrack(direction)

Parameters:

NameTypeDescription
direction ? ?

Declared on: line 581 of Lua/audio.lua.

function Audio:playSound(name, where, is_announcement, played_callback, played_callback_delay, loops)

Play a sound from the sound archive

Parameters:

NameTypeDescription
name string The name of the sound to be played. Can include wildcards (*).
where Entity The entity that is the source of the sound, or nil if the audio is not positional.
is_announcement boolean Whether the sound is an announcement (affects volume).
played_callback function A function to be called when the sound has finished playing. Can be nil.
played_callback_delay integer An optional delay in milliseconds before the played_callback is called.
loops integer number of times to play the audio. -1 for infinite.

Declared on: line 316 of Lua/audio.lua.

function Audio:playSoundEffects(play_effects)

Parameters:

NameTypeDescription
play_effects ? ?

Declared on: line 798 of Lua/audio.lua.

function Audio:readPlaylistPreferences()

Load the playlist disabled tracks file

Declared on: line 857 of Lua/audio.lua.

function Audio:releaseChannel(channel)

Parameters:

NameTypeDescription
channel ? ?

Declared on: line 843 of Lua/audio.lua.

function Audio:resolveFilenameWildcard(name)

Resolves sound filename containing wildcard character from its associated variants

Parameters:

NameTypeDescription
name string Filename containing wildcard character to resolve

Declared on: line 420 of Lua/audio.lua.

function Audio:setAnnouncementVolume(volume)

Parameters:

NameTypeDescription
volume ? ?

Declared on: line 823 of Lua/audio.lua.

function Audio:setBackgroundVolume(volume)

Parameters:

NameTypeDescription
volume ? ?

Declared on: line 776 of Lua/audio.lua.

function Audio:setSoundStage()

Set the visual area for sound effects playback

Declared on: line 283 of Lua/audio.lua.

function Audio:setSoundVolume(volume)

Parameters:

NameTypeDescription
volume ? ?

Declared on: line 789 of Lua/audio.lua.

function Audio:soundExists(sound)

Returns whether the given sound (either a string or a number)

exists in the sound archive

Parameters:

NameTypeDescription
sound ? The sound to look for, either a string (name) or a number (position in the list of sounds)

Declared on: line 542 of Lua/audio.lua.

function Audio:stopBackgroundTrack()

Stops playing background music for the time being.

Does not affect the configuration setting play_music.

Declared on: line 665 of Lua/audio.lua.

function Audio:stopSound(sound)

Stop a playing sound. A stopped sound is destroyed and cannot be resumed. The callback will be not be called for the stopped sound.

Parameters:

NameTypeDescription
sound table The `sound` table returned by `Audio:playSound`.

Declared on: line 374 of Lua/audio.lua.

function Audio:togglePauseSound(sound)

Pause or unpause a playing sound

Parameters:

NameTypeDescription
sound table The `sound` table returned by `Audio:playSound`.

Declared on: line 361 of Lua/audio.lua.

function Audio:updatePlaylistPreferences()

Create a set of playlist filenames that are disabled and write this to file

Declared on: line 870 of Lua/audio.lua.