local musicVol = getObject('Values[val_musicVol]') -- get value for storing music volume
local soundVol = getObject('Values[val_soundVol]') -- get value for storing sound volume
local speechVol = getObject('Values[val_speechVol]') -- get value for storing speech volume
local getCond = getObject('Conditions[cond_muteSound]') -- get condition for checking if sound is muted or playing
-- let's create a function to toggle sound muted / playing!
function toggleSound()
local cond = getCond:getBool(VConditionValue) -- check condition value
if not cond then
getCond:setValue(VConditionValue, true) -- set condition to true
musicVol:setValue(VValueInt, getVolume(eMusicVolume)) -- store current music volume
soundVol:setValue(VValueInt, getVolume(eSoundVolume)) -- store current sound volume
speechVol:setValue(VValueInt, getVolume(eSpeechVolume)) -- store current speech volume
setVolume(eMusicVolume, 0) -- set music volume to "0"
setVolume(eSoundVolume, 0) -- set sound volume to "0"
setVolume(eSpeechVolume, 0) -- set speech volume to "0"
else
getCond:setValue(VConditionValue, false) -- set condition to false!
setVolume(eMusicVolume, musicVol) -- restore music volume
setVolume(eSoundVolume, soundVol) -- restore sound volume
setVolume(eSpeechVolume, speechVol) -- restore speech volume
end
end