mirror of
https://github.com/UberGames/rpgxEF.git
synced 2025-04-22 08:50:48 +00:00
Add constants to lua libray trace and sound.
Examples: trace.CONSTANT.MASK_SHOT sound.CONSTANT.CHAN_AUTO
This commit is contained in:
parent
0242b959ae
commit
da77688e30
2 changed files with 103 additions and 48 deletions
|
@ -1,48 +1,64 @@
|
|||
// sound lib for lua
|
||||
|
||||
#include "g_lua.h"
|
||||
|
||||
#ifdef G_LUA
|
||||
|
||||
/***
|
||||
A documentation to play sounds.
|
||||
@module sound
|
||||
*/
|
||||
|
||||
/***
|
||||
Play a sound on a given entity.
|
||||
@function PlaySound
|
||||
@param ent The entity the sound will be played on
|
||||
@param sound The sound file which will be played
|
||||
@param chan The sound channel the sound will be played on
|
||||
*/
|
||||
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 1;
|
||||
|
||||
sound = (char*)luaL_checkstring(L,2);
|
||||
if(!sound[0]) return 1;
|
||||
|
||||
chan = luaL_checknumber(L,3);
|
||||
|
||||
snd = G_SoundIndex(sound);
|
||||
G_AddEvent(l->e, EV_SCRIPT_SOUND, snd + (chan << 8));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
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
|
||||
// sound lib for lua
|
||||
|
||||
#include "g_lua.h"
|
||||
#include "q_shared.h"
|
||||
|
||||
#ifdef G_LUA
|
||||
|
||||
/***
|
||||
A documentation to play sounds.
|
||||
@module sound
|
||||
*/
|
||||
|
||||
/***
|
||||
Play a sound on a given entity.
|
||||
@function PlaySound
|
||||
@param ent The entity the sound will be played on
|
||||
@param sound The sound file which will be played
|
||||
@param chan The sound channel the sound will be played on
|
||||
*/
|
||||
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 1;
|
||||
|
||||
sound = (char*)luaL_checkstring(L,2);
|
||||
if(!sound[0]) return 1;
|
||||
|
||||
chan = luaL_checknumber(L,3);
|
||||
|
||||
snd = G_SoundIndex(sound);
|
||||
G_AddEvent(l->e, EV_SCRIPT_SOUND, snd + (chan << 8));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const luaL_Reg lib_sound[] = {
|
||||
{ "PlaySound", Sound_PlaySound },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
int Luaopen_Sound(lua_State *L) {
|
||||
luaL_register(L, "sound", lib_sound);
|
||||
|
||||
/* add contants */
|
||||
lua_pushstring(L, "CONSTANTS");
|
||||
lua_newtable(L);
|
||||
Lua_RegConstInteger(L, CHAN_ANNOUNCER);
|
||||
Lua_RegConstInteger(L, CHAN_AUTO);
|
||||
Lua_RegConstInteger(L, CHAN_BODY);
|
||||
Lua_RegConstInteger(L, CHAN_ITEM);
|
||||
Lua_RegConstInteger(L, CHAN_LOCAL);
|
||||
Lua_RegConstInteger(L, CHAN_LOCAL_SOUND);
|
||||
Lua_RegConstInteger(L, CHAN_MENU1);
|
||||
Lua_RegConstInteger(L, CHAN_VOICE);
|
||||
Lua_RegConstInteger(L, CHAN_WEAPON);
|
||||
lua_settable(L, -3);
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -234,6 +234,45 @@ int Luaopen_Trace(lua_State *L) {
|
|||
luaL_register(L, NULL, Trace_meta);
|
||||
luaL_register(L, "trace", lib_trace);
|
||||
|
||||
/* Add constants */
|
||||
lua_pushstring(L, "CONSTANTS");
|
||||
lua_newtable(L);
|
||||
Lua_RegConstInteger(L, CONTENTS_NONE);
|
||||
Lua_RegConstInteger(L, CONTENTS_SOLID);
|
||||
Lua_RegConstInteger(L, CONTENTS_LAVA);
|
||||
Lua_RegConstInteger(L, CONTENTS_SLIME);
|
||||
Lua_RegConstInteger(L, CONTENTS_WATER);
|
||||
Lua_RegConstInteger(L, CONTENTS_FOG);
|
||||
Lua_RegConstInteger(L, CONTENTS_LADDER);
|
||||
Lua_RegConstInteger(L, CONTENTS_AREAPORTAL);
|
||||
Lua_RegConstInteger(L, CONTENTS_PLAYERCLIP);
|
||||
Lua_RegConstInteger(L, CONTENTS_MONSTERCLIP);
|
||||
Lua_RegConstInteger(L, CONTENTS_SHOTCLIP);
|
||||
Lua_RegConstInteger(L, CONTENTS_TELEPORTER);
|
||||
Lua_RegConstInteger(L, CONTENTS_JUMPPAD);
|
||||
Lua_RegConstInteger(L, CONTENTS_ITEM);
|
||||
Lua_RegConstInteger(L, CONTENTS_CLUSTERPORTAL);
|
||||
Lua_RegConstInteger(L, CONTENTS_DONOTENTER);
|
||||
Lua_RegConstInteger(L, CONTENTS_BOTCLIP);
|
||||
Lua_RegConstInteger(L, CONTENTS_ORIGIN);
|
||||
Lua_RegConstInteger(L, CONTENTS_BODY);
|
||||
Lua_RegConstInteger(L, CONTENTS_CORPSE);
|
||||
Lua_RegConstInteger(L, CONTENTS_DETAIL);
|
||||
Lua_RegConstInteger(L, CONTENTS_STRUCTURAL);
|
||||
Lua_RegConstInteger(L, CONTENTS_TRANSLUCENT);
|
||||
Lua_RegConstInteger(L, CONTENTS_TRIGGER);
|
||||
Lua_RegConstInteger(L, CONTENTS_NODROP);
|
||||
Lua_RegConstInteger(L, MASK_ALL);
|
||||
Lua_RegConstInteger(L, MASK_SOLID);
|
||||
Lua_RegConstInteger(L, MASK_PLAYERSOLID);
|
||||
Lua_RegConstInteger(L, MASK_DEADSOLID);
|
||||
Lua_RegConstInteger(L, MASK_WATER);
|
||||
Lua_RegConstInteger(L, MASK_OPAQUE);
|
||||
Lua_RegConstInteger(L, MASK_SHOT);
|
||||
Lua_RegConstInteger(L, MASK_ONLYPLAYER);
|
||||
Lua_RegConstInteger(L, MASK_BRUSHES);
|
||||
lua_settable(L, -3);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue