Fixes to some Getters and Setters for lua entity lib as well as a few new getters and setters.

This commit is contained in:
UberGames 2011-07-28 18:00:52 +02:00
parent aaa362beea
commit cf0a8dfaea

View file

@ -910,7 +910,7 @@ static int Entity_SetApos1(lua_State *L) {
vec_t *vec; vec_t *vec;
lent = Lua_GetEntity(L, 1); lent = Lua_GetEntity(L, 1);
if(!lent || lent->e) if(!lent || !lent->e)
return 1; return 1;
vec = Lua_GetVector(L, 2); vec = Lua_GetVector(L, 2);
@ -924,7 +924,7 @@ static int Entity_SetApos2(lua_State *L) {
vec_t *vec; vec_t *vec;
lent = Lua_GetEntity(L, 1); lent = Lua_GetEntity(L, 1);
if(!lent || lent->e) if(!lent || !lent->e)
return 1; return 1;
vec = Lua_GetVector(L, 2); vec = Lua_GetVector(L, 2);
@ -1701,7 +1701,7 @@ static int Entity_GetModel2(lua_State *L) {
lent_t *lent; lent_t *lent;
lent = Lua_GetEntity(L, 1); lent = Lua_GetEntity(L, 1);
if(!lent || lent->e) if(!lent || !lent->e)
lua_pushnil(L); lua_pushnil(L);
else else
lua_pushstring(L, lent->e->model2); lua_pushstring(L, lent->e->model2);
@ -2523,6 +2523,86 @@ static int Entity_GetTakedamage(lua_State *L) {
return 1; return 1;
} }
static int Entity_SetTarget(lua_State *L) {
lent_t *lent;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
return 1;
lent->e->target = (char *)luaL_checkstring(L, 2);
return 1;
}
static int Entity_GetTargetname2(lua_State *L) {
lent_t *lent;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
lua_pushnil(L);
else
lua_pushstring(L, lent->e->targetname2);
return 1;
}
static int Entity_SetTargetname2(lua_State *L) {
lent_t *lent;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
return 1;
lent->e->targetname2 = (char *)luaL_checkstring(L, 2);
return 1;
}
static int Entity_GetTargetShaderName(lua_State *L) {
lent_t *lent;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
lua_pushnil(L);
else
lua_pushstring(L, lent->e->targetShaderName);
return 1;
}
static int Entity_SetTargetShaderName(lua_State *L) {
lent_t *lent;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
return 1;
lent->e->targetShaderName = (char *)luaL_checkstring(L, 2);
return 1;
}
static int Entity_GetTargetShaderNewName(lua_State *L) {
lent_t *lent;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
lua_pushnil(L);
else
lua_pushstring(L, lent->e->targetShaderNewName);
return 1;
}
static int Entity_SetTargetShaderNewName(lua_State *L) {
lent_t *lent;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
return 1;
lent->e->targetShaderNewName = (char *)luaL_checkstring(L, 2);
return 1;
}
static const luaL_Reg Entity_ctor[] = { static const luaL_Reg Entity_ctor[] = {
{"Spawn", Entity_Spawn}, {"Spawn", Entity_Spawn},
{"Find", Entity_Find}, {"Find", Entity_Find},
@ -2766,12 +2846,23 @@ static const luaL_Reg Entity_meta[] = {
{"GetTakedamage", Entity_GetTakedamage}, // args: none; return: bool {"GetTakedamage", Entity_GetTakedamage}, // args: none; return: bool
{"SetTarget", Entity_SetTarget}, // args: string; return: nothing
{"GetTargetname2", Entity_GetTargetname2}, // args: none; return: string
{"SetTargetname2", Entity_SetTargetname2}, // args: string; return: nothing
{"GetTargetShaderName", Entity_GetTargetShaderName}, // args: none; return: string
{"SetTargetShaderName", Entity_SetTargetShaderName}, // args: string; return: nothing
{"GetTargetShaderNewName", Entity_GetTargetShaderNewName}, // args: none; return: string
{"SetTargetShaderNewName", Entity_SetTargetShaderNewName}, // args: string; return: nothing
{NULL, NULL} {NULL, NULL}
}; };
/*void dummy(gentity_t *ent) { void dummy(gentity_t *ent) {
ent->target; ent->targetShaderName;
}*/ }
int Luaopen_Entity(lua_State * L) int Luaopen_Entity(lua_State * L)
{ {