Some minor fixes...

This commit is contained in:
UberGames 2011-08-02 13:55:24 +02:00
parent bc4ea34bba
commit f10493a98d
5 changed files with 129 additions and 6 deletions

View file

@ -260,6 +260,7 @@
<ClCompile Include="lua.c" />
<ClCompile Include="luac.c" />
<ClCompile Include="lua_cinematic.c" />
<ClCompile Include="lua_cvar.c" />
<ClCompile Include="lua_game.c" />
<ClCompile Include="lua_entity.c" />
<ClCompile Include="g_active.c">

View file

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

View file

@ -2552,6 +2552,113 @@ static int Entity_SetTargetShaderNewName(lua_State *L) {
return 1;
}
static int Entity_GetTargetEnt(lua_State *L) {
lent_t *lent;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
lua_pushnil(L);
else
Lua_PushEntity(L, lent->e->target_ent);
return 1;
}
static int Entity_SetTargetEnt(lua_State *L) {
lent_t *lent;
lent_t *targ;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
return 1;
targ = Lua_GetEntity(L, 2);
if(!targ || !targ->e)
return 1;
lent->e->target_ent = targ->e;
return 1;
}
static int Entity_GetTeam(lua_State *L) {
lent_t *lent;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
lua_pushnil(L);
else
lua_pushstring(L, lent->e->team);
return 1;
}
static int Entity_SetTeam(lua_State *L) {
lent_t *lent;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
return 1;
lent->e->team = (char *)luaL_checkstring(L, 2);
return 1;
}
static int Entity_GetTeamchain(lua_State *L) {
lent_t *lent;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
lua_pushnil(L);
else
Lua_PushEntity(L, lent->e->teamchain);
return 1;
}
static int Entity_SetTeamchain(lua_State *L) {
lent_t *lent;
lent_t *team;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
return 1;
team = Lua_GetEntity(L, 2);
if(!team || !team->e)
return 1;
lent->e->teamchain = team->e;
return 1;
}
static int Entity_GetTeammaster(lua_State *L) {
lent_t *lent;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
lua_pushnil(L);
else
Lua_PushEntity(L, lent->e->teammaster);
return 1;
}
static int Entity_SetTeammaster(lua_State *L) {
lent_t *lent;
lent_t *team;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
return 1;
team = Lua_GetEntity(L, 2);
if(!team || !team->e)
return 1;
lent->e->teammaster = team->e;
return 1;
}
static const luaL_Reg Entity_ctor[] = {
{"Spawn", Entity_Spawn},
{"Find", Entity_Find},
@ -2808,12 +2915,24 @@ static const luaL_Reg Entity_meta[] = {
{"GetTargetShaderNewName", Entity_GetTargetShaderNewName}, // args: none; return: string
{"SetTargetShaderNewName", Entity_SetTargetShaderNewName}, // args: string; return: nothing
{"GetTargetEnt", Entity_GetTargetEnt}, // args: none; return: ent
{"SetTargetEnt", Entity_SetTargetEnt}, // args: ent; return: nothing
{"GetTeam", Entity_GetTeam}, // args: none; return: string
{"SetTeam", Entity_SetTeam}, // args: string; return nothing
{"GetTeamchain", Entity_GetTeamchain}, // args: none; return: ent
{"SetTeamchain", Entity_SetTeamchain}, // args: ent; return: nothing
{"GetTeammaster", Entity_GetTeammaster},
{"SetTeammaster", Entity_SetTeammaster},
{NULL, NULL}
};
/*void dummy(gentity_t *ent) {
ent->targetShaderName;
}*/
void dummy(gentity_t *ent) {
ent->timestamp;
}
int Luaopen_Entity(lua_State * L)
{

View file

@ -11,17 +11,17 @@ static int Sound_PlaySound(lua_State *L) {
lent_t *l;
l = Lua_GetEntity(L,1);
if(!l || !l->e) return 0;
if(!l || !l->e) return 1;
sound = (char*)luaL_checkstring(L,2);
if(!sound[0]) return 0;
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 0;
return 1;
}
static const luaL_Reg lib_sound[] = {

Binary file not shown.