Definition
bool GetSoundLoop(string soundObjectName)
Description
This function returns the state of the sound loop as a Boolean value of true or false.
Parameters
soundObjectName
Specifies the ambient or 3D sound name. You can also use the name “this” for this parameter. In this case, “this” string refers to the name of the sound to which this script is attached.
Return Value
If the state of the loop is true, it returns true, otherwise it returns false.
Example 1
sound_loop = false message = "" function Init() sound_loop = GetSoundLoop("sound1") if sound_loop then message = string.format("\nSound Loop is ON") else message = string.format("\nSound Loop is OFF") end PrintConsole(message) end function Update() end
First, we specify the loop state of “sound1”. Then we display its status in the console using the PrintConsole function.
Example 2
--Name of script is GetSoundLoop2.lua sound_loop = false message = "" function Init() sound_loop = GetSoundLoop("this") if sound_loop then message = string.format("\nSound Loop is ON") else message = string.format("\nSound Loop is OFF") end PrintConsole(message) end function Update() end
Assume that the above script named GetSoundLoop2.lua is attached to a sound object named “sound1”. In this case, string “this” in the GetSoundLoop function will be equal to “sound1”. In our example, the function GetSoundLoop returns the loop state of the sound “sound1”.
GetSoundLoop