Difference between revisions of "Global Command: getVolume"

From The Official Visionaire Studio: Adventure Game Engine Wiki
m
 
(One intermediate revision by the same user 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"
Allows the user to check current volume levels of: music, sound, speech, video, & master.
+
|-
<div class="toccolours mw-collapsible mw-collapsed tbl-ds">
+
| style="width:15%" | Related functions
<span class="bold">Additional Info</span>
+
| [[Global Command: setVolume|setVolume]]
<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>
+
<syntaxhighlight lang="lua">
 
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%?
 
if getVolume(eSoundVolume) < 25 then
 
-- do some action!
 
end
 
  
-- is speech volume more than or equal to 80%?
+
{| class="ts"
if getVolume(eSpeechVolume) >= 80 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 movie volume at 50%?
 
if getVolume(eMovieVolume) == 50 then
 
-- do some action!
 
end
 
  
-- is global (master) volume not equal to 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(eGlobalVolume) ~= 50 then
+
|-
-- do some action!
+
| eSoundVolume (1)
end
+
|-
</syntaxhighlight>
+
| eSpeechVolume (2)
Example 2: using integer values instead
+
|-
<syntaxhighlight>
+
| eMovieVolume (3)
getVolume(0) -- is the same as...
+
|-
getVolume(eMusicVolume)
+
| eGlobalVolume (4)
</syntaxhighlight>
+
|}
  
  
 +
== Return values ==
  
<span class="bold underline">Arguments</span>
+
{| class="ts"
 +
|-
 +
! style="width:15%" | Type
 +
! Description
 +
|-
 +
| integer
 +
| The queried volume level in the range of 0 to 100.
 +
|}
  
<span class="bold">type</span>: integer (number) <br/>
 
The type of volume to return: eMusicVolume(0), eSoundVolume(1), eSpeechVolume(2), eMovieVolume(3) or eGlobalVolume(4)
 
  
 +
== Examples ==
  
<span class="bold underline">Flags</span>
+
'''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
  
none
+
-- 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
<span class="bold underline">Return</span>
+
end
 
+
</syntaxhighlight>
<span class="bold">volume</span> <br/>
+
{{toc}}
The queried volume
 
 
 
 
 
 
 
{| class="tbl-ds"
 
|-
 
|<span class="bold">Relevant Pages</span>: [[SetVolume_(CMS)|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