Difference between revisions of "SetVolume"
From The Official Visionaire Studio: Adventure Game Engine Wiki
Line 1: | Line 1: | ||
<div class="toccolours mw-collapsible mw-collapsed" style="background: #f0f0f0; border: 1px dashed darkgrey" width="100%"> | <div class="toccolours mw-collapsible mw-collapsed" style="background: #f0f0f0; border: 1px dashed darkgrey" width="100%"> | ||
− | <b>History</b | + | <b>Command History</b> |
<div class="mw-collapsible-content"> | <div class="mw-collapsible-content"> | ||
− | MovieVolume & GlobalVolume added to <span style="color: | + | <div style="background:#ebebeb" width="100%">Available since <span style="color:orange">v3.7</span></div> |
+ | <div>MovieVolume & GlobalVolume added to <span style="color:orange">v3.8</span></div> | ||
</div></div> | </div></div> | ||
Allows the user to set volume levels of: music, sound fx, speech, movies & global(master) | Allows the user to set volume levels of: music, sound fx, speech, movies & global(master) | ||
− | + | <div class="toccolours mw-collapsible mw-collapsed" style="background: #f0f0f0; border: 1px dashed darkgrey" width="100%"> | |
− | + | <b>Additional Info</b> | |
− | + | <div class="mw-collapsible-content"> | |
− | + | <div>These are the numbers used inside of the setVolume(brackets) to set specific volume types! <br/> | |
− | 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> | |
− | |||
Line 68: | Line 68: | ||
--]] | --]] | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
<b><u>Arguments</u></b> | <b><u>Arguments</u></b> | ||
− | type: integer <br/> | + | type: integer (number) <br/> |
The type of volume to set: eMusicVolume (0), eSoundVolume (1), eSpeechVolume (2), eMovieVolume (3) or eGlobalVolume (4) | The type of volume to set: eMusicVolume (0), eSoundVolume (1), eSpeechVolume (2), eMovieVolume (3) or eGlobalVolume (4) | ||
− | volume: integer <br/> | + | volume: integer (number) <br/> |
New value for volume. Must be a value between 0 and 100 | New value for volume. Must be a value between 0 and 100 | ||
Revision as of 18:54, 7 March 2013
Command History
Available since v3.7
MovieVolume & GlobalVolume added to v3.8
Allows the user to set volume levels of: music, sound fx, speech, movies & global(master)
Additional Info
These are the numbers used inside of the setVolume(brackets) to set specific volume types!
eMusicVolume (0), eSoundVolume (1), eSpeechVolume (2), eMovieVolume (3) or eGlobalVolume (4)
Syntax:
setVolume(type, volume)
Example 1: basic set volume
-- 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)
Example 2: set all levels based on global (master) volume! [pre v3.8]
-- let's set the global (master) volume to 80%
local globalVol = 80
-- let's create a variable containing difference between global volume current & max volume!
local dif = 100 - globalVol
-- let's store the current volumes for the various volume types into variables!
local musicVol = getVolume(0)
local sfxVol = getVolume(1)
local speechVol = getVolume(2)
-- let's remove the difference from the various volume types!
setVolume(0, musicVol - dif)
setVolume(1, sfxVol - dif)
setVolume(2, speechVol - 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
--[[
this is of course completely unnecessary as the volumes are automatically adjusted with the global volume command
added to v3.8!
--]]
Arguments
type: integer (number)
The type of volume to set: eMusicVolume (0), eSoundVolume (1), eSpeechVolume (2), eMovieVolume (3) or eGlobalVolume (4)
volume: integer (number)
New value for volume. Must be a value between 0 and 100
Flags: none
Return: none