Difference between revisions of "SetVolume"

From The Official Visionaire Studio: Adventure Game Engine Wiki
(Created page with "<b>History</b>: Available since <span style="color:green">v3.7</span> <br/> MovieVolume & GlobalVolume added to <span style="color:green">v3.8</span> Allows the user to set v...")
 
(Redirected page to Global Command: setVolume)
 
(18 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<b>History</b>: Available since <span style="color:green">v3.7</span> <br/>
+
#REDIRECT [[Global Command: setVolume]]
MovieVolume & GlobalVolume added to <span style="color:green">v3.8</span>
 
 
 
Allows the user to set volume levels of: music, sound fx, speech, movies & global(master)
 
{| class="mw-collapsible mw-collapsed" style="background: #f0f0f0; border: 1px dashed darkgrey" width="100%"
 
! Additional Info
 
|-
 
|
 
These are the numbers used inside of the setVolume(brackets) to set specific volume types! <br/>
 
eMusicVolume (0), eSoundVolume (1), eSpeechVolume (2), eMovieVolume (3) or eGlobalVolume (4)
 
|}
 
 
 
 
 
Syntax:
 
<syntaxhighlight>
 
setVolume(type, volume)
 
</syntaxhighlight>
 
 
 
Example 1: basic set volume
 
<syntaxhighlight>
 
-- set music volume to 50%!
 
setVolume(0, 50)
 
 
 
-- set sound fx volume to 50%!
 
setVolume(1, 50)
 
 
 
-- set speech volume to 50%!
 
setVolume(2, 50)
 
 
 
-- set movie volume to 50%!
 
setVolume(3, 50)
 
 
 
-- set global (master) volume to 50%!
 
setVolume(4, 50)
 
</syntaxhighlight>
 
 
 
Example 2: set all levels based on global (master) volume!
 
<syntaxhighlight>
 
-- let's set the global (master) volume to 80%
 
setVolume(4, 80)
 
 
 
-- let's create a variable containing difference between global volume current & max volume!
 
local dif = 100 - getVolume(4)
 
 
 
-- let's store the current volumes for the various volume types into variables!
 
local getMusicVol = getVolume(0)
 
local getSfxVol = getVolume(1)
 
local getSpeechVol = getVolume(2)
 
local getMovieVol = getVolume(3)
 
 
 
-- let's remove the difference from the various volume types!
 
setVolume(0, getMovieVol - dif)
 
setVolume(1, getSfxVol - dif)
 
setVolume(2, getSpeechVol - dif)
 
setVolume(3, getMovieVol - dif)
 
 
 
-- let's check none of the various volume types are under 0%!
 
if getVolume(0) < 0 then setVolume(0, 0) end
 
if getVolume(1) < 0 then setVolume(1, 0) end
 
if getVolume(2) < 0 then setVolume(2, 0) end
 
if getVolume(3) < 0 then setVolume(3, 0) end
 
 
 
--[[
 
this is of course completely unnecessary as the volumes are automatically adjusted with the global volume ...
 
you could have used a similar method in this to create a global volume function before it was included in v3.8!
 
--]]
 
</syntaxhighlight>
 
 
 
 
 
<b><u>Arguments</u></b>
 
 
 
type: integer <br/>
 
The type of volume to set: eMusicVolume (0), eSoundVolume (1), eSpeechVolume (2), eMovieVolume (3) or eGlobalVolume (4)
 
 
 
volume: integer <br/>
 
New value for volume. Must be a value between 0 and 100
 
 
 
Flags: none
 
 
 
Return: none
 
{{i18n|setVolume}}
 

Latest revision as of 12:31, 19 May 2023