SetSoundLoop

Definition

SetSoundLoop(string soundObjectName, bool loop)

Description

This function sets the loop state of the sound soundObjectName to 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.

loop
Specifies the state of the sound loop. Accepted values are true or false.

Example 1

function Init()
    SetSoundLoop("sound1"false)
    PlaySound("sound1")
end

function Update()

end
First, we set the loop status of “sound1” to false. Then we play “sound1”. Since the loop status of sound “sound1” is false, this sound will only be played once.

Example 2

--Name of script is SetSoundLoop2.lua

function Init()
    SetSoundLoop("this"true)
    PlaySound("this")
end

function Update()

end
Assume that the above script named SetSoundLoop2.lua is attached to a sound object named “sound1”. In this case, string “this”  in the SetSoundLoop function will be equal to “sound1”.
In our example, we set the loop state of current sound, which is “sound1”, to true. Then we play current sound, which is “sound1”. Since the loop status of current sound is true, this sound will be played continuously.
adminSetSoundLoop