Difference between revisions of "Mute/Restore Volume (CMS)"
From The Official Visionaire Studio: Adventure Game Engine Wiki
m |
|||
(21 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | {| class=" | + | {| class="ts" style="width:100%" |
|- | |- | ||
− | ! style="text-align:left" | Name !! style="text-align:left | + | ! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By |
|- | |- | ||
− | | Mute/Restore Volume || Definition || AFRLme | + | | Mute/Restore Volume || Definition || [https://www.patreon.com/AFRLme AFRLme] |
|} | |} | ||
This script allows you to mute or restore the volume for all sound types; it is also possible from Visionaire Studio 4.0 onwards to mute/restore volume via the new eGlobalVolume command. see [[#eGlobalVolume_Method|eGlobalVolume Method]]. | This script allows you to mute or restore the volume for all sound types; it is also possible from Visionaire Studio 4.0 onwards to mute/restore volume via the new eGlobalVolume command. see [[#eGlobalVolume_Method|eGlobalVolume Method]]. | ||
− | + | {| class="toccolours mw-collapsible mw-collapsed ts" | |
− | + | |- | |
− | + | ! Additional Info | |
− | + | |- | |
− | + | | Volume types currently available... | |
− | + | |- | |
+ | | eMusicVolume(0), eSoundVolume(1), eSpeechVolume(2), eMovieVolume(3), eGlobalVolume(4) | ||
+ | |} | ||
== Instructions == | == Instructions == | ||
− | 1. Add the [[#Main_Script|main script]] to the Visionaire Studio Script Editor & set the script as a definition script.<br/> | + | 1. Add the [[#Main_Script|main script]] to the Visionaire Studio Script Editor & set the script as a definition script.<br /> |
− | 2. Create condition "cond_mute" & set default value to <span class="red">''false''</span>.<br/> | + | 2. Create condition "cond_mute" & set default value to <span class="red">''false''</span>.<br /> |
− | 3. Create 5 values | + | 3. Create 5 values '''vol_0''', '''vol_1''', '''vol_2''', '''vol_3''' & '''vol_4''' - these will be used to store volumes values.<br /> |
− | 4. To mute/restore volume add an ''execute a script'' to a key input, button or scene object, containing... | + | 4. To mute/restore volume: add an ''execute a script'' action to a key input, button or scene object, containing... |
− | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
globalMute() | globalMute() | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Main Script == | == Main Script == | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
--[[ | --[[ | ||
Mute/Restore Volume [V1] (20/03/2014) | Mute/Restore Volume [V1] (20/03/2014) | ||
Written by AFRLme [Lee Clarke] | Written by AFRLme [Lee Clarke] | ||
-- + -- | -- + -- | ||
− | + | email: afrlme@outlook.com | |
+ | paypal: afrlme@zoho.com | ||
+ | patreon: https://www.patreon.com/AFRLme | ||
+ | portfolio: https://afrl.me | ||
-- + -- | -- + -- | ||
This script is donation optional. In game credit is non-negotiable. | This script is donation optional. In game credit is non-negotiable. | ||
Line 43: | Line 48: | ||
function globalMute() | function globalMute() | ||
if not cond:getBool(VConditionValue) then -- if not muted then... | if not cond:getBool(VConditionValue) then -- if not muted then... | ||
− | for i = 0, 4 do | + | for i = 0, 4 do -- (0, 2) if you are still on 3.7.1 or below (eMovieVolume(3) & eGlobalVolume(4) from visionaire studio 4.0 onwards) |
getObject("Values[vol_" .. i .. "]"):setValue(VValueInt, getVolume(i)) -- store volume i into linked editor value | getObject("Values[vol_" .. i .. "]"):setValue(VValueInt, getVolume(i)) -- store volume i into linked editor value | ||
setVolume(i, 0) -- set volume i to 0 | setVolume(i, 0) -- set volume i to 0 | ||
Line 49: | Line 54: | ||
cond:setValue(VConditionValue, true) -- set muted condition to true | cond:setValue(VConditionValue, true) -- set muted condition to true | ||
else -- if already muted then do... | else -- if already muted then do... | ||
− | for i = 0, 4 do | + | for i = 0, 4 do -- (0, 2) if you are still on 3.7.1 or below (eMovieVolume(3) & eGlobalVolume(4) from visionaire studio 4.0 onwards) |
setVolume(i, getObject("Values[vol_" .. i .. "]"):getInt(VValueInt)) -- return volume level for i based on linked editor value | setVolume(i, getObject("Values[vol_" .. i .. "]"):getInt(VValueInt)) -- return volume level for i based on linked editor value | ||
end | end | ||
Line 59: | Line 64: | ||
== eGlobalVolume Method == | == eGlobalVolume Method == | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
+ | --[[ | ||
+ | Mute/Restore Volume (global method; visionaire studio 4.0+ only) [V1] (20/03/2014) | ||
+ | Written by AFRLme [Lee Clarke] | ||
+ | -- + -- | ||
+ | email: afrlme@outlook.com | ||
+ | paypal: afrlme@zoho.com | ||
+ | patreon: https://www.patreon.com/AFRLme | ||
+ | portfolio: https://afrl.me | ||
+ | -- + -- | ||
+ | This script is donation optional. In game credit is non-negotiable. | ||
+ | You are free to: ¹ use it in your game(s). ² modify the script. | ||
+ | Do not remove - or edit - this comment block. | ||
+ | --]] | ||
+ | |||
-- * local variables * -- | -- * local variables * -- | ||
local cond = getObject("Conditions[cond_mute]") -- store muted condition | local cond = getObject("Conditions[cond_mute]") -- store muted condition | ||
Line 68: | Line 87: | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | <br/> | + | <br /> |
− | {| class=" | + | {| class="ts" |
|- | |- | ||
− | | | + | | '''Relevant Pages''': [[Volume_Control_(CMS)|Volume Control]] |
− | |} | + | |}{{toc}} |
Latest revision as of 12:34, 15 September 2022
Name | Type | By |
---|---|---|
Mute/Restore Volume | Definition | AFRLme |
This script allows you to mute or restore the volume for all sound types; it is also possible from Visionaire Studio 4.0 onwards to mute/restore volume via the new eGlobalVolume command. see eGlobalVolume Method.
Additional Info |
---|
Volume types currently available... |
eMusicVolume(0), eSoundVolume(1), eSpeechVolume(2), eMovieVolume(3), eGlobalVolume(4) |
Instructions
1. Add the main script to the Visionaire Studio Script Editor & set the script as a definition script.
2. Create condition "cond_mute" & set default value to false.
3. Create 5 values vol_0, vol_1, vol_2, vol_3 & vol_4 - these will be used to store volumes values.
4. To mute/restore volume: add an execute a script action to a key input, button or scene object, containing...
globalMute()
Main Script
--[[
Mute/Restore Volume [V1] (20/03/2014)
Written by AFRLme [Lee Clarke]
-- + --
email: afrlme@outlook.com
paypal: afrlme@zoho.com
patreon: https://www.patreon.com/AFRLme
portfolio: https://afrl.me
-- + --
This script is donation optional. In game credit is non-negotiable.
You are free to: ¹ use it in your game(s). ² modify the script.
Do not remove - or edit - this comment block.
--]]
-- * local variables * --
local cond = getObject("Conditions[cond_mute]") -- store muted condition
-- * function that determines if sound should be muted or restored * --
function globalMute()
if not cond:getBool(VConditionValue) then -- if not muted then...
for i = 0, 4 do -- (0, 2) if you are still on 3.7.1 or below (eMovieVolume(3) & eGlobalVolume(4) from visionaire studio 4.0 onwards)
getObject("Values[vol_" .. i .. "]"):setValue(VValueInt, getVolume(i)) -- store volume i into linked editor value
setVolume(i, 0) -- set volume i to 0
end
cond:setValue(VConditionValue, true) -- set muted condition to true
else -- if already muted then do...
for i = 0, 4 do -- (0, 2) if you are still on 3.7.1 or below (eMovieVolume(3) & eGlobalVolume(4) from visionaire studio 4.0 onwards)
setVolume(i, getObject("Values[vol_" .. i .. "]"):getInt(VValueInt)) -- return volume level for i based on linked editor value
end
cond:setValue(VConditionValue, false) -- set muted condition to false
end
-- startVolSlider() -- uncomment this line if you are also using the volume slider script
end
eGlobalVolume Method
--[[
Mute/Restore Volume (global method; visionaire studio 4.0+ only) [V1] (20/03/2014)
Written by AFRLme [Lee Clarke]
-- + --
email: afrlme@outlook.com
paypal: afrlme@zoho.com
patreon: https://www.patreon.com/AFRLme
portfolio: https://afrl.me
-- + --
This script is donation optional. In game credit is non-negotiable.
You are free to: ¹ use it in your game(s). ² modify the script.
Do not remove - or edit - this comment block.
--]]
-- * local variables * --
local cond = getObject("Conditions[cond_mute]") -- store muted condition
-- * function that determines if sound should be muted or restored * --
function globalMute()
if not cond:getBool(VConditionValue) then setVolume(eGlobalVolume, 0); cond:setValue(VConditionValue, true) else setVolume(eGlobalVolume, 100); cond:setValue(VConditionValue, false) end
end
Relevant Pages: Volume Control |