lol don't know what I fixed/added anymore sorry

This commit is contained in:
UberGames 2011-07-19 13:51:15 +02:00
parent 0eed14f78c
commit 2a1f7b4263
7 changed files with 47 additions and 1 deletions

View file

@ -72,7 +72,8 @@ OBJ = \
lua_vector.o \
lua_mover.o \
lua_qmath.o \
lua_cinematic.o
lua_cinematic.o \
lua_sound.o
# game object for syscalls to the engine
SOOBJ = \
@ -170,6 +171,7 @@ lua_mover.o: lua_mover.c; $(DO_CC)
lua_qmath.o: lua_qmath.c; $(DO_CC)
lua_vector.o: lua_vector.c; $(DO_CC)
lua_cinematic.o: lua_cinematic.c; $(DO_CC)
lua_sound.o: lua_sound.c; $(DO_CC)
# game syscalls
g_syscalls.o : g_syscalls.c; $(DO_CC)

View file

@ -272,6 +272,7 @@ qboolean G_LuaStartVM(lvm_t * vm)
Luaopen_Vector(vm->L);
Luaopen_Entity(vm->L);
Luaopen_Cinematic(vm->L);
Luaopen_Sound(vm->L);
res = luaL_loadbuffer(vm->L, vm->code, vm->code_size, vm->filename);
if(res == LUA_ERRSYNTAX)

View file

@ -77,4 +77,7 @@ int Luaopen_Mover(lua_State *L);
// lua_cinematic.c
int Luaopen_Cinematic(lua_State *L);
// lua_sound.c
int Luaopen_Sound(lua_State *L);
#endif

View file

@ -449,6 +449,7 @@
</ClCompile>
<ClCompile Include="lua_mover.c" />
<ClCompile Include="lua_qmath.c" />
<ClCompile Include="lua_sound.c" />
<ClCompile Include="lundump.c" />
<ClCompile Include="lvm.c" />
<ClCompile Include="lzio.c" />

View file

@ -264,6 +264,9 @@
<ClCompile Include="lua_cinematic.c">
<Filter>Source Files\lua</Filter>
</ClCompile>
<ClCompile Include="lua_sound.c">
<Filter>Source Files\lua</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ai_chat.h">

36
game/lua_sound.c Normal file
View file

@ -0,0 +1,36 @@
// sound lib for lua
#include "g_lua.h"
#ifdef G_LUA
static int Sound_PlaySound(lua_State *L) {
char *sound;
int snd;
int chan;
lent_t *l;
l = Lua_GetEntity(L,1);
if(!l || l->e) return 0;
sound = (char*)luaL_checkstring(L,2);
if(!sound[0]) return 0;
chan = luaL_checknumber(L,3);
snd = G_SoundIndex(sound);
G_AddEvent(l->e, EV_SCRIPT_SOUND, snd + (chan << 8));
return 0;
}
static const luaL_Reg lib_sound[] = {
{"PlaySound", Sound_PlaySound},
{NULL, NULL}
};
int Luaopen_Sound(lua_State *L) {
luaL_register(L, "sound", lib_sound);
return 1;
}
#endif

Binary file not shown.