Difference between revisions of "StartSound"

From The Official Visionaire Studio: Adventure Game Engine Wiki
Line 1: Line 1:
 
==startSound==
 
==startSound==
  
<div class="command-min-version-info">Available since: <span class="command-min-version">v3.8</span></div>
+
<div class="command-min-version-info">Available since: <span class="command-min-version">v4.0</span></div>
  
 
<div class="command-doc">Plays a sound file.</div>
 
<div class="command-doc">Plays a sound file.</div>
Line 40: Line 40:
 
startSound('vispath:sounds/example.ogg', {flags=1, volume=70, balance=-10, offset=1000})
 
startSound('vispath:sounds/example.ogg', {flags=1, volume=70, balance=-10, offset=1000})
 
</syntaxhighlight>
 
</syntaxhighlight>
[[Category:Player Commands]]
 

Revision as of 21:28, 30 September 2014

startSound

Available since: v4.0
Plays a sound file.

Lua Syntax:

startSound(sounditem, {flags=1, 
    volume = int, 
    balance = int, 
    loop = true|false, 
    offset = int})

Arguments

sounditem

"string" (string should contain 'vispath:' prefix) - Relative filename of sound which should be started.

Flags

vol/volume

Sound volume (0 ... mute, 100 ... full volume), default value is 100.

bal/balance

Sound balance (-100 ... left, 0 ... center, +100 right), default value is 0.

lop/loop

If true then loop sound, otherwise play it only once (default).

ofs/offset

Set the sound to a specific offset (seek) in milliseconds. Default value is 0.

Return Values

soundID
Unique id referencing the started sound or -1 if the sound could not be started.

Examples

Example 1: play audio file, store sound id (for later use) and update sound balance of currently started sound

local soundId = startSound('vispath:sounds/example.ogg')
setSoundProperty(soundId, {flags=1, balance=40})

Example 2: play audio file and set volume, balance and offset

startSound('vispath:sounds/example.ogg', {flags=1, volume=70, balance=-10, offset=1000})