[GS] Any idea on how to control the music track played in game?

__jack__

Warlord
Joined
Dec 29, 2009
Messages
141
Hi,

I would like to call a specific music track using lua ? Any experience with this ?
 
There is UI.PlaySound(x) for sounds and UI.SetSoundSwitchValue(y,z).
The later one seems to be controling music, but I am unsure on how to use them.
 
Yeah, those are only used in User Interface mode on the Diplomacy and Game Loading screens. You won't for example be able to use anything UI.X in a GameplayScript.

SetSoundSwitchValue has only limited choices for the first parameter
Code:
"Leader_Screen_Civilization"
"Civilization"
"Era_DawnOfMan"
"LEADER_SCREEN_CIVILIZATION"
"Game_Location"
The second parameter appears to be a Wwise Sound (music) internal ID number.
 
I play it in my Portugal mod (using playsound), I choose my music, but i used a script that runs in interface mode from here: https://forums.civfanatics.com/threads/tutorial-adding-music-to-your-mod-civilization.621830/

I have read these thread (a very interesting one) - but my problem is that here I want to play the existing music - somehow I can't managed to call it reliably
Yeah, those are only used in User Interface mode on the Diplomacy and Game Loading screens. You won't for example be able to use anything UI.X in a GameplayScript..

That would work - I planned to use it via UI Script probably using the chat panel with a set of command like play track or next track.
My issue is that I don't seem to be able to reliably call a track: I am assuming for music you need to use SetSoundSwitchValue and then PlaySound in a specific manner.
 
You have to find events and use playsound only, playsound("stop_..... Playsound ("play_, or something like that. Don't know if plays internal since I was worried about my music at the time.

Example from my mod:
Spoiler :

if (iPlayerEra > iCurrentGameEra) then
-- Stop Portugal Music
UI.PlaySound("Stop_Music_PORTUGAL");
if(iPlayerEra ==2) then
UI.PlaySound("Stop_Ancient_Music_PORTUGAL");
UI.PlaySound("Play_Classical_Music_PORTUGAL");
elseif(iPlayerEra ==3) then
UI.PlaySound("Stop_Classical_Music_PORTUGAL");
UI.PlaySound("Play_Medieval_Music_PORTUGAL");
.....
 
Last edited:
You have to find events and use playsound only, playsound("stop_..... Playsound ("play_, or something like that. Don't know if plays internal since I was worried about my music at the time.

Yes I am familiar with this - I do suspect the internal music have something along UI.Playsound("Music") and then uses SetSoundSwitchValue to feed different track.... However if we would have the internal music "event" we could call them individually.
 
Top Bottom