Difference between revisions of "Mute/Restore Volume (CMS)"
From The Official Visionaire Studio: Adventure Game Engine Wiki
m |
m |
||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{| class="ts" style="width:100%" | {| class="ts" style="width:100%" | ||
|- | |- | ||
− | ! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By | + | ! 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] |
|} | |} | ||
Line 18: | Line 18: | ||
== 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 '''vol_0''', '''vol_1''', '''vol_2''', '''vol_3''' & '''vol_4''' - these will be used to store volumes values.<br/> | + | 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'' action 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 61: | Line 64: | ||
== eGlobalVolume Method == | == eGlobalVolume Method == | ||
− | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
--[[ | --[[ | ||
Mute/Restore Volume (global method; visionaire studio 4.0+ only) [V1] (20/03/2014) | Mute/Restore Volume (global method; visionaire studio 4.0+ only) [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 81: | Line 87: | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | <br/> | + | <br /> |
{| class="ts" | {| class="ts" | ||
|- | |- | ||
| '''Relevant Pages''': [[Volume_Control_(CMS)|Volume Control]] | | '''Relevant Pages''': [[Volume_Control_(CMS)|Volume Control]] | ||
|}{{toc}} | |}{{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 |