Module music
Music Lua module.
Typical usage would be something like:
music.choose( "combat" ) -- Starts a combat song music.play() -- Play it, it should play automatically unless music is stopped music.play( "machina.ogg" ) -- You can also directly define the name of the file to play instead
Functions
choose (situation) | Delays a rechoose. |
play ([filename=nil]) | Plays the loaded song. |
pause (disable) | Pauses the music engine. |
stop (nodisable) | Stops playing the current song. |
isPlaying () | Checks to see if something is playing. |
current () | Gets the name of the current playing song. |
getVolume (log) | Gets the volume level of the music. |
Functions
- choose (situation)
-
Delays a rechoose.
Parameters:
- situation string Situation to choose.
Usage:
music.choose( "ambient" ) -- Rechooses ambient in 5 seconds
- play ([filename=nil])
-
Plays the loaded song. Will resume paused songs.
Parameters:
- filename string Name of the file to play, or just the current loaded one if not set. (default nil)
- pause (disable)
-
Pauses the music engine.
Parameters:
- disable boolean Whether or not to disable music changes until music.play() is called. This disables all in-game music changes such as taking off.
- stop (nodisable)
-
Stops playing the current song.
Parameters:
- nodisable boolean Whether or not to disable music changes until music.play() is called. This disables all in-game music changes such as taking off. Disables by false, set to true to only stop the current song.
- isPlaying ()
-
Checks to see if something is playing.
Returns:
-
boolean
true if something is playing.
- current ()
-
Gets the name of the current playing song.
Returns:
- string The name of the current playing song or "none" if no song is playing.
- number The current offset inside the song (-1. if music is none).
Usage:
songname, songplayed = music.current()
- getVolume (log)
-
Gets the volume level of the music.
Parameters:
- log boolean Whether or not to get the volume in log scale.
Returns:
-
number
Volume level of the music.