Added a Lua function for playing sound files.

This commit is contained in:
Guillaume Melquiond 2010-07-26 21:21:06 +00:00
parent 2518c6d155
commit 12371ef7a2

View file

@ -2222,6 +2222,20 @@ static int intf_set_music(lua_State *L)
return 0;
}
/**
* Plays a sound, possibly repeated.
* - Arg 1: string.
* - Arg 2: optional integer.
*/
static int intf_play_sound(lua_State *L)
{
char const *m = luaL_checkstring(L, 1);
if (resources::controller->is_skipping_replay()) return 0;
int repeats = lua_tointeger(L, 2);
sound::play_sound(m, sound::SOUND_FX, repeats);
return 0;
}
/**
* Scrolls to given tile.
* - Args 1,2: location.
@ -2313,6 +2327,7 @@ LuaKernel::LuaKernel()
{ "get_village_owner", &intf_get_village_owner },
{ "is_enemy", &intf_is_enemy },
{ "message", &intf_message },
{ "play_sound", &intf_play_sound },
{ "put_recall_unit", &intf_put_recall_unit },
{ "put_unit", &intf_put_unit },
{ "require", &intf_require },