naev 0.12.5
nlua_music.c File Reference

Lua music playing module. More...

#include "nlua_music.h"
#include "music.h"
#include "nluadef.h"
Include dependency graph for nlua_music.c:

Go to the source code of this file.

Functions

static int musicL_choose (lua_State *L)
 Delays a rechoose.
static int musicL_play (lua_State *L)
 Plays the loaded song. Will resume paused songs.
static int musicL_pause (lua_State *L)
 Pauses the music engine.
static int musicL_stop (lua_State *L)
 Stops playing the current song.
static int musicL_isPlaying (lua_State *L)
 Checks to see if something is playing.
static int musicL_current (lua_State *L)
 Gets the name of the current playing song.
static int musicL_getVolume (lua_State *L)
 Gets the volume level of the music.
int nlua_loadMusic (nlua_env env)
 Music Lua module.

Variables

static const luaL_Reg music_methods []

Detailed Description

Lua music playing module.

Definition in file nlua_music.c.

Function Documentation

◆ musicL_choose()

int musicL_choose ( lua_State * L)
static

Delays a rechoose.

Lua usage parameter: music.choose( "ambient" ) – Rechooses ambient in 5 seconds

Lua function parameter: string situation Situation to choose.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: choose

Definition at line 66 of file nlua_music.c.

◆ musicL_current()

int musicL_current ( lua_State * L)
static

Gets the name of the current playing song.

Lua usage parameter: songname, songplayed = music.current()

Lua return parameter: string The name of the current playing song or "none" if no song is playing. Lua return parameter: number The current offset inside the song (-1. if music is none).

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: current

Definition at line 152 of file nlua_music.c.

◆ musicL_getVolume()

int musicL_getVolume ( lua_State * L)
static

Gets the volume level of the music.

Lua function parameter: boolean log Whether or not to get the volume in log scale. Lua return parameter: number Volume level of the music.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: getVolume

Definition at line 174 of file nlua_music.c.

◆ musicL_isPlaying()

int musicL_isPlaying ( lua_State * L)
static

Checks to see if something is playing.

Lua return parameter: boolean true if something is playing.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: isPlaying

Definition at line 128 of file nlua_music.c.

◆ musicL_pause()

int musicL_pause ( lua_State * L)
static

Pauses the music engine.

Lua function parameter: boolean disable Whether or not to disable music changes until music.play() is called. This disables all in-game music changes such as taking off.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: pause

Definition at line 97 of file nlua_music.c.

◆ musicL_play()

int musicL_play ( lua_State * L)
static

Plays the loaded song. Will resume paused songs.

Lua function parameter:[opt=nil] string filename Name of the file to play, or just the current loaded one if not set.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: play

Definition at line 81 of file nlua_music.c.

◆ musicL_stop()

int musicL_stop ( lua_State * L)
static

Stops playing the current song.

Lua function parameter: boolean disable 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 stop music until "music.play()" is run.

Parameters
LLua State
Returns
Number of variables on the Lua State stack.

Lua function: stop

Definition at line 114 of file nlua_music.c.

◆ nlua_loadMusic()

int nlua_loadMusic ( nlua_env env)

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

Lua module: music

Loads the music functions into a lua_State.

Parameters
envLua environment to load the music functions into.
Returns
0 on success.

Definition at line 52 of file nlua_music.c.

Variable Documentation

◆ music_methods

const luaL_Reg music_methods[]
static
Initial value:
= {
{ "choose", musicL_choose },
{ "play", musicL_play },
{ "pause", musicL_pause },
{ "stop", musicL_stop },
{ "isPlaying", musicL_isPlaying },
{ "current", musicL_current },
{ "getVolume", musicL_getVolume },
{ 0, 0 } }
static int musicL_isPlaying(lua_State *L)
Checks to see if something is playing.
Definition nlua_music.c:128
static int musicL_choose(lua_State *L)
Delays a rechoose.
Definition nlua_music.c:66
static int musicL_play(lua_State *L)
Plays the loaded song. Will resume paused songs.
Definition nlua_music.c:81
static int musicL_stop(lua_State *L)
Stops playing the current song.
Definition nlua_music.c:114
static int musicL_current(lua_State *L)
Gets the name of the current playing song.
Definition nlua_music.c:152
static int musicL_pause(lua_State *L)
Pauses the music engine.
Definition nlua_music.c:97
static int musicL_getVolume(lua_State *L)
Gets the volume level of the music.
Definition nlua_music.c:174

Music specific methods.

Definition at line 23 of file nlua_music.c.