Difference between revisions of "Global Command: getVolume"

From The Official Visionaire Studio: Adventure Game Engine Wiki
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<div class="toccolours mw-collapsible mw-collapsed tbl-ds">
+
Retrieve the general volume levels for music, sound, speech, videos, and master.  
<span class="bold">Function History</span>
 
<div class="mw-collapsible-content">
 
<div class="alt-bg">Available since v3.0</div>
 
<div>MovieVolume & GlobalVolume added to v3.8</div>
 
</div></div>
 
  
 +
{| class="ts"
 +
|-
 +
| style="width:15%" | Related functions
 +
| [[Global Command: setVolume|setVolume]]
 +
|}
  
Allows the user to check current volume levels of: music, sound, speech, video, & master.
 
<div class="toccolours mw-collapsible mw-collapsed tbl-ds">
 
<span class="bold">Additional Info</span>
 
<div class="mw-collapsible-content">
 
<div>These are the names or numbers used inside of the getVolume(''brackets'') to check specific volume types. <br/>
 
<pre>eMusicVolume(0), eSoundVolume(1), eSpeechVolume(2), eMovieVolume(3), or eGlobalVolume(4)</pre></div>
 
</div></div>
 
  
 
+
== Syntax ==
Syntax:
+
<syntaxhighlight lang="lua">
<syntaxhighlight>
 
 
getVolume(type)
 
getVolume(type)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
  
Example 1: recommended getVolume() method
+
== Parameters ==
<syntaxhighlight>
 
-- is music volume over 50%?
 
if getVolume(eMusicVolume) > 50 then
 
-- do some action!
 
end
 
  
-- is sound fx volume less than 25%?
+
{| class="ts"
if getVolume(eSoundVolume) < 25 then
+
|-
-- do some action!
+
! style="width:15%" | Parameter
end
+
! style="width:10%" | Type
 +
! style="width:15%" | Supported values
 +
! Description
 +
|-
 +
| rowspan="5" | type
 +
| rowspan="5" | integer
 +
| eMusicVolume (0)
 +
| rowspan="5" | The type of volume to return.
  
-- is speech volume more than or equal to 80%?
 
if getVolume(eSpeechVolume) >= 80 then
 
-- do some action!
 
end
 
  
-- is movie volume at 50%?
+
''The available types are members of the [https://www.visionaire-studio.com/luadocs/lua.html#sound-volume-types sound volume enumeration]. The parameter can be passed as name (e.&nbsp;g. eMusicVolume), or number (e.&nbsp;g. 0), see the examples.''
if getVolume(eMovieVolume) == 50 then
+
|-
-- do some action!
+
| eSoundVolume (1)
end
+
|-
 +
| eSpeechVolume (2)
 +
|-
 +
| eMovieVolume (3)
 +
|-
 +
| eGlobalVolume (4)
 +
|}
  
-- is global (master) volume not equal to 50%?
 
if getVolume(eGlobalVolume) ~= 50 then
 
-- do some action!
 
end
 
</syntaxhighlight>
 
Example 2: using integer values instead
 
<syntaxhighlight>
 
getVolume(eMusicVolume)
 
-- is the same as...
 
getVolume(0)
 
</syntaxhighlight>
 
  
 +
== Return values ==
  
 +
{| class="ts"
 +
|-
 +
! style="width:15%" | Type
 +
! Description
 +
|-
 +
| integer
 +
| The queried volume level in the range of 0 to 100.
 +
|}
  
<span class="bold underline">Arguments</span>
 
  
<span class="bold">type</span>: integer (number) <br/>
+
== Examples ==
The type of volume to return: eMusicVolume(0), eSoundVolume(1), eSpeechVolume(2), eMovieVolume(3) or eGlobalVolume(4)
 
  
 +
'''Example 1:''' Enable the text output, if the speech volume level is below 30.
 +
<syntaxhighlight lang="lua">
 +
if getVolume(eSpeechVolume) < 30 then
 +
  game.TextOutput = eTextAndSpeechOutput
 +
end
  
<span class="bold underline">Flags</span>
+
-- You can also pass the volume type as an integer. The following code will do the same.
 
+
if getVolume(2) < 30 then
none
+
  game.TextOutput = eTextAndSpeechOutput
 
+
end
 
+
</syntaxhighlight>
<span class="bold underline">Return</span>
+
{{toc}}
 
 
<span class="bold">volume</span> <br/>
 
The queried volume
 
 
 
 
 
 
 
 
 
{| class="tbl-ds"
 
|-
 
|<span class="bold">Relevant Pages</span>: [[SetVolume|setVolume]]
 
|}
 

Latest revision as of 22:28, 4 May 2023

Retrieve the general volume levels for music, sound, speech, videos, and master.

Related functions setVolume


Syntax

getVolume(type)


Parameters

Parameter Type Supported values Description
type integer eMusicVolume (0) The type of volume to return.


The available types are members of the sound volume enumeration. The parameter can be passed as name (e. g. eMusicVolume), or number (e. g. 0), see the examples.

eSoundVolume (1)
eSpeechVolume (2)
eMovieVolume (3)
eGlobalVolume (4)


Return values

Type Description
integer The queried volume level in the range of 0 to 100.


Examples

Example 1: Enable the text output, if the speech volume level is below 30.

if getVolume(eSpeechVolume) < 30 then
  game.TextOutput = eTextAndSpeechOutput
end

-- You can also pass the volume type as an integer. The following code will do the same.
if getVolume(2) < 30 then
  game.TextOutput = eTextAndSpeechOutput
end