Add lua support for playing background music

This commit is contained in:
abcdefg30
2015-10-12 14:42:59 +02:00
parent 76ada5176f
commit 4afef8868e
2 changed files with 20 additions and 0 deletions

View File

@@ -95,6 +95,18 @@ namespace OpenRA.Mods.Common.Scripting
playlist.Play(musicInfo);
}
[Desc("Play track defined in music.yaml or map.yaml as background music." +
" If music is already playing use Media.StopMusic() to stop it" +
" and the background music will start automatically." +
" Keep the track empty to disable background music.")]
public void SetBackgroundMusic(string track = null)
{
if (!playlist.IsMusicAvailable)
return;
playlist.SetBackgroundMusic(string.IsNullOrEmpty(track) ? null : world.Map.Rules.Music[track]);
}
[Desc("Stop the current song.")]
public void StopMusic()
{