View Single Post
03/11/23, 05:52 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
If you just want to change the volume of that 1 sound just call PlaySound with the same parameters more than once. It will get louder that way but that does not work with all sounds of the SOUNDS table! So you need to test it.

Lua Code:
  1. PlaySound(SOUNDS.VOLUME_DING_ALL)
  2. PlaySound(SOUNDS.VOLUME_DING_ALL) --should make it 2times as loud as normal
  3. PlaySound(SOUNDS.VOLUME_DING_ALL) --should make it 3times as loud as normal

About your question with the settings:
Changing the overall sound volume will affect ALL sounds played and other effects too so it might make your whole game be loud, not only that 1 sound
If you want to achieve this you need to use the GetSetting* and SetSetting* API functions to set/get the correct category and index in that category.
There should be one category constant for the audio settings e.g. and then different index constants for the volumes.
You can fidn those at the vailla source code, where the settings menu is build:

https://github.com/esoui/esoui/blob/...shared.lua#L11

If I'm not wrong the main category(or system) would be SETTING_TYPE_AUDIO and the index AUDIO_SETTING_AUDIO_VOLUME

Code:
--- @param system [SettingSystemType|#SettingSystemType]
--- @param settingId integer
--- @param value string
--- @param setOptions [SetOptions|#SetOptions]
--- @return void
function SetSetting(system, settingId, value, setOptions) end

--- @param system [SettingSystemType|#SettingSystemType]
--- @param settingId integer
--- @return value string
function GetSetting(system, settingId) end

--- @param system [SettingSystemType|#SettingSystemType]
--- @param settingId integer
--- @return value bool
function GetSetting_Bool(system, settingId) end
Afaik the value you pass in to SetSetting must be a string! So convert the value you want to set via tostring(valueToSet)
and if you use GetSetting convert that value with tonumber(GetSetting(SETTING_TYPE_AUDIO, AUDIO_SETTING_AUDIO_VOLUME)) so you can do mathematics with it properly (allthough lua should accept mathematics with string numbers too I guess :-) )

Last edited by Baertram : 03/11/23 at 05:59 AM.
  Reply With Quote