Draft: Lua media package, allows manipulating sound, music, video. Includes Music interface to dehardcode music in the future.
Just the start here. Let me know the changes that need to be made and I will see them fixed.
This MR adds in openmw.media, which can be used to playSound, check soundPlaying, stopMusic, check musicPlaying, startTitle(music), getPlaylist(gets a list of music files), and playVideo.
OpenMW.media can only be called from player scripts.
It also adds the Music library, which attaches 2 scripts:
- To the player. Will update on every frame. Checks for music playing, and for combat. Will play death music when the player dies, and finishes their animation.
- To NPCs/Creatures. Will check with onUpdate if they are in combat with Player. If they are, will send an event to the player to add them to their list of combat targets. It will send a combatEnded event when they die, are no longer in combat with the player, or during inActive.
If the player has more than 0 combat targets, combat music is played. If they have 0, the "normal" music is played, which is "explore" by default. Mods can use the Music Library to change this, for example to add in music from Oblivion, and play "public" music in towns and cities, and Dungeon music in dungeons.
A function is also added to types.Actor, to allow checking that the death animation is finished, which is when you need to play the death music.
Mods can also disable the music system entirely, and reimplement it to their liking.
This is a draft, and before it can be merged, the following issues need to be resolved:
- Remove commented out lines that disable hardcoded music
- Add in more functions to media and Music. Should be able to disable combat music, for example.
- Finish settings menu for interface
- Verify that music works exactly as before. It seems close, but I think it exits combat music a little quickly.
- Re-add level up music. Currently does not happen.
- Main menu music also does not work. Not sure how we could run lua code outside of a game.
However, I want to see if this is close to something that could be merged. If it's way off base, let me know.