naev 0.11.5
nlua_music.c File Reference

Lua music playing module. More...

#include "nlua_music.h"
#include "log.h"
#include "music.h"
#include "ndata.h"
#include "nluadef.h"

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()

static 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 72 of file nlua_music.c.

◆ musicL_current()

static 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 150 of file nlua_music.c.

◆ musicL_getVolume()

static 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 173 of file nlua_music.c.

◆ musicL_isPlaying()

static 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 127 of file nlua_music.c.

◆ musicL_pause()

static 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 99 of file nlua_music.c.

◆ musicL_play()

static int musicL_play ( lua_State * L)
static

Plays the loaded song. Will resume paused songs.

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

Lua function: play

Definition at line 85 of file nlua_music.c.

◆ musicL_stop()

static int musicL_stop ( lua_State * L)
static

Stops playing the current song.

Lua function parameter: boolean nodisable 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.

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

Lua function: stop

Definition at line 113 of file nlua_music.c.

◆ nlua_loadMusic()

int nlua_loadMusic ( nlua_env env)

Music Lua module.

Typical usage would be something like:

music.load( "intro" ) -- Load the song
music.play() -- Play it

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 58 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:127
static int musicL_choose(lua_State *L)
Delays a rechoose.
Definition nlua_music.c:72
static int musicL_play(lua_State *L)
Plays the loaded song. Will resume paused songs.
Definition nlua_music.c:85
static int musicL_stop(lua_State *L)
Stops playing the current song.
Definition nlua_music.c:113
static int musicL_current(lua_State *L)
Gets the name of the current playing song.
Definition nlua_music.c:150
static int musicL_pause(lua_State *L)
Pauses the music engine.
Definition nlua_music.c:99
static int musicL_getVolume(lua_State *L)
Gets the volume level of the music.
Definition nlua_music.c:173

Music specific methods.

Definition at line 30 of file nlua_music.c.