Difference between revisions of "Global Command: setVolume"

From The Official Visionaire Studio: Adventure Game Engine Wiki
(Created page with "<div class="toccolours mw-collapsible mw-collapsed tbl-ds"> <span class="bold">Function History</span> <div class="mw-collapsible-content"> <div class="alt-bg">Available since...")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
<div class="toccolours mw-collapsible mw-collapsed tbl-ds">
+
Set 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 set volume levels of: music, sound fx, 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: getVolume|getVolume]]
<div class="mw-collapsible-content">
+
|}
<div>These are the numbers used inside of the setVolume(''brackets'') to set 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">
 
setVolume(type, volume)
 
setVolume(type, volume)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
  
Example 1: recommended method
+
== Parameters ==
<syntaxhighlight>
 
-- set music volume to 50%!
 
setVolume(eMusicVolume, 50)
 
  
-- set sound fx volume to 50%!
+
{| class="ts"
setVolume(eSoundVolume, 50)
+
|-
 +
! style="width:15%" | Parameter
 +
! 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.
  
-- set speech volume to 50%!
 
setVolume(eSpeechVolume, 50)
 
  
-- set movie volume 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.''
setVolume(eMovieVolume, 50)
+
|-
 +
| eSoundVolume (1)
 +
|-
 +
| eSpeechVolume (2)
 +
|-
 +
| eMovieVolume (3)
 +
|-
 +
| eGlobalVolume (4)
 +
|-
 +
| volume
 +
| integer
 +
|
 +
| The new value for volume in the range of 0 to 100.
 +
|}
  
-- set global (master) volume to 50%!
 
setVolume(eGlobalVolume, 50)
 
</syntaxhighlight>
 
Example 2: using integer values instead
 
<syntaxhighlight>
 
setVolume(0, 50) -- is the same as...
 
setVolume(eMusicVolume, 50)
 
</syntaxhighlight>
 
  
 
+
== Return values ==
 
 
<span class="bold underline">Arguments</span>
 
 
 
<span class="bold">type</span>: integer (number) <br/>
 
The type of volume to set: eMusicVolume(0), eSoundVolume(1), eSpeechVolume(2), eMovieVolume(3) or eGlobalVolume(4)
 
 
 
<span class="bold">volume</span>: integer (number) <br/>
 
New value for volume. Must be a value between 0 and 100
 
 
 
 
 
<span class="bold underline">Flags</span>
 
  
 
none
 
none
  
  
<span class="bold underline">Return</span>
+
== Examples ==
  
none
+
'''Example 1:''' Set the speech volume level to 80.
 +
<syntaxhighlight lang="lua">
 +
setVolume(eSpeechVolume, 80)
  
 
+
-- You can also pass the volume type as an integer. The following code will do the same.
 
+
setVolume(2, 80)
{| class="tbl-ds"
+
</syntaxhighlight>
|-
+
{{toc}}
|<span class="bold">Relevant Pages</span>: [[GetVolume_(CMS)|getVolume]]
 
|}
 

Latest revision as of 21:37, 4 May 2023

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

Related functions getVolume


Syntax

setVolume(type, volume)


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)
volume integer The new value for volume in the range of 0 to 100.


Return values

none


Examples

Example 1: Set the speech volume level to 80.

setVolume(eSpeechVolume, 80)

-- You can also pass the volume type as an integer. The following code will do the same.
setVolume(2, 80)