Difference between revisions of "StartSound"

From The Official Visionaire Studio: Adventure Game Engine Wiki
(Redirected page to Global Command: startSound)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
==startSound==
+
#REDIRECT [[Global Command: startSound]]
 
 
<div class="command-min-version-info">Available since: <span class="command-min-version">v3.8</span></div>
 
 
 
<div class="command-doc">Plays a sound file.</div>
 
 
 
Lua Syntax:
 
<pre class="command-syntax">startSound(sounditem, {flags=1,
 
    volume = int,
 
    balance = int,
 
    loop = true|false,
 
    offset = int})</pre>
 
===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
 
<syntaxhighlight>
 
local soundId = startSound('vispath:sounds/example.ogg')
 
setSoundProperty(soundId, {flags=1, balance=40})
 
</syntaxhighlight>
 
Example 2: play audio file and set volume, balance and offset
 
<syntaxhighlight>
 
startSound('vispath:sounds/example.ogg', {flags=1, volume=70, balance=-10, offset=1000})
 
</syntaxhighlight>
 
[[Category:Player Commands]]
 

Latest revision as of 12:35, 19 May 2023