Difference between revisions of "GetSoundId"

From The Official Visionaire Studio: Adventure Game Engine Wiki
Line 1: Line 1:
<div class="toccolours mw-collapsible mw-collapsed tbl-ds">
+
==getSoundId==
<span class="bold">Command History</span>
 
<div class="mw-collapsible-content">
 
<div class="alt-bg">Available since v3.8</div>
 
</div></div>
 
  
 +
<div class="command-min-version-info">Available since: <span class="command-min-version">v3.8</span></div>
  
Use this to store the sound.id for an audio file into a variable; which you can use to stop/pause/resume or edit the linked sounds properties!
+
<div class="command-doc">Gets the sound ID of the specified sound if it is currently active.</div>
 
 
 
 
 
 
Syntax:
 
<syntaxhighlight>
 
getSoundId("filename")
 
</syntaxhighlight>
 
 
 
  
 +
Lua Syntax:
 +
<pre class="command-syntax">getSoundId(sounditem)</pre>
 +
===Arguments===
 +
====sounditem====
 +
:'''"string" (string should contain 'vispath:' prefix)''' - Relative filename of sound.
 +
===Flags===
 +
===Return Values===
 +
;soundID
 +
:Unique id referencing the requested sound or -1 if the sound is not active.
 +
===Examples===
 +
Example 1:
 
<syntaxhighlight>
 
<syntaxhighlight>
-- let's store the sound ID into a variable for later use!
+
-- store sound id of a currently active sound in a local variable
local soundID = getSoundId("sounds/example.ogg")
+
local soundID = getSoundId('vispath:sounds/example.ogg')
 
</syntaxhighlight>
 
</syntaxhighlight>
 
 
 
<span class="bold underline">Arguments</span>
 
 
<span class="bold">filename</span>: path <br/>
 
The path to the audio file whose ID we want to obtain! ("path/filename.type")
 
 
 
<span class="bold underline">Flags</span>
 
 
none
 
 
 
<span class="bold underline">Return</span>
 
 
<span class="bold">id</span> <br/>
 
Returns the sound ID as an integer value.
 
{{i18n|GetSoundId}} <br/>
 
{| class="tbl-ds"
 
|-
 
|<span class="bold">Relevant Pages</span>: [[GetSoundProperty|getSoundProperty]] - [[SetSoundProperty|setSoundProperty]] - [[StartSound|startSound]] - [[StopSound|stopSound]] - [[ToggleSoundPause|toggleSoundPause]]
 
|}
 

Revision as of 17:11, 22 November 2013

getSoundId

Available since: v3.8
Gets the sound ID of the specified sound if it is currently active.

Lua Syntax:

getSoundId(sounditem)

Arguments

sounditem

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

Flags

Return Values

soundID
Unique id referencing the requested sound or -1 if the sound is not active.

Examples

Example 1:

-- store sound id of a currently active sound in a local variable
local soundID = getSoundId('vispath:sounds/example.ogg')