Even more getters and setters... and I'm far from finished xD.

This commit is contained in:
UberGames 2011-07-26 18:19:18 +02:00
parent ef8ad59929
commit 5d200c8947
2 changed files with 459 additions and 102 deletions

View file

@ -1807,151 +1807,508 @@ static int Entity_SetLuaUse(lua_State *L) {
return 1; return 1;
} }
static int Entity_GetMessage(lua_State *L) {
lent_t *lent;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e) {
lua_pushstring(L, "");
return 1;
}
if(!lent->e->luaDie[0]) {
lua_pushstring(L, "");
} else {
lua_pushstring(L, lent->e->message);
}
return 1;
}
static int Entity_SetMessage(lua_State *L) {
lent_t *lent;
char *s;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
return 1;
s = (char *)luaL_checkstring(L, 2);
if(!s[0])
lent->e->message = NULL;
else
lent->e->message = G_NewString(s);
return 1;
}
static int Entity_GetMethodOfDeath(lua_State *L) {
lent_t *lent;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e) {
lua_pushinteger(L, 0);
return 1;
}
lua_pushinteger(L, lent->e->methodOfDeath);
return 1;
}
static int Entity_SetMethodOfDeath(lua_State *L) {
lent_t *lent;
int mod;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
return 1;
mod = (int)luaL_checknumber(L, 1);
lent->e->methodOfDeath = mod;
return 1;
}
static int Entity_GetModel(lua_State *L) {
lent_t *lent;
lent = Lua_GetEntity(L, 1);
if(!lent || lent->e) {
lua_pushstring(L, "");
return 1;
}
if(!lent->e->model[0])
lua_pushstring(L, "");
else
lua_pushstring(L, lent->e->model);
return 1;
}
static int Entity_SetModel(lua_State *L) {
lent_t *lent;
char *s;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
return 1;
s = (char *)luaL_checkstring(L, 2);
if(!s[0])
lent->e->model = NULL;
else
lent->e->model = G_NewString(s);
return 1;
}
static int Entity_GetModel2(lua_State *L) {
lent_t *lent;
lent = Lua_GetEntity(L, 1);
if(!lent || lent->e) {
lua_pushstring(L, "");
return 1;
}
if(!lent->e->model[0])
lua_pushstring(L, "");
else
lua_pushstring(L, lent->e->model2);
return 1;
}
static int Entity_SetModel2(lua_State *L) {
lent_t *lent;
char *s;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
return 1;
s = (char *)luaL_checkstring(L, 2);
if(!s[0])
lent->e->model2 = NULL;
else
lent->e->model2 = G_NewString(s);
return 1;
}
static int Entity_GetMovedir(lua_State *L) {
lent_t *lent;
vec3_t null = { 0, 0, 0 };
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e) {
Lua_PushVector(L, null);
return 1;
}
Lua_PushVector(L, lent->e->movedir);
return 1;
}
static int Entity_SetMovedir(lua_State *L) {
lent_t *lent;
vec_t *dir;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
return 1;
dir = Lua_GetVector(L, 2);
VectorCopy(dir, lent->e->movedir);
return 1;
}
static int Entity_GetMoverstate(lua_State *L) {
lent_t *lent;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e) {
lua_pushinteger(L, -1);
return 1;
}
lua_pushinteger(L, (int)lent->e->moverState);
return 1;
}
static int Entity_SetMoverstate(lua_State *L) {
lent_t *lent;
moverState_t m;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
return 1;
m = (moverState_t)luaL_checknumber(L, 2);
lent->e->moverState = m;
return 1;
}
static int Entity_GetN00bCount(lua_State *L) {
lent_t *lent;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e) {
lua_pushinteger(L, 0);
return 1;
}
lua_pushinteger(L, lent->e->n00bCount);
return 1;
}
static int Entity_SetN00bCount(lua_State *L) {
lent_t *lent;
int cnt;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
return 1;
cnt = (int)luaL_checknumber(L, 2);
lent->e->n00bCount = cnt;
return 1;
}
static int Entity_GetNeverFree(lua_State *L) {
lent_t *lent;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e) {
lua_pushboolean(L, 0);
return 1;
}
lua_pushboolean(L, (int)lent->e->neverFree);
return 1;
}
static int Entity_SetNeverFree(lua_State *L) {
lent_t *lent;
qboolean b;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
return 1;
b = (qboolean)lua_toboolean(L, 2);
lent->e->neverFree = b;
return 1;
}
static int Entity_GetNexthink(lua_State *L) {
lent_t *lent;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e) {
lua_pushinteger(L, -1);
return 1;
}
lua_pushinteger(L, lent->e->nextthink);
return 1;
}
static int Entity_SetNexthink(lua_State *L) {
lent_t *lent;
int next;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
return 1;
next = (int)luaL_checknumber(L, 2);
lent->e->nextthink = next;
return 1;
}
static int Entity_GetNextTrain(lua_State *L) {
lent_t *lent;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e) {
lua_pushnil(L);
return 1;
}
if(!lent->e->nextTrain) {
lua_pushnil(L);
} else {
Lua_PushEntity(L, lent->e->nextTrain);
}
return 1;
}
static int Entity_SetNextTrain(lua_State *L) {
lent_t *lent;
lent_t *next;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
return 1;
next = Lua_GetEntity(L, 2);
if(!next || !next->e)
lent->e->nextTrain = NULL;
else
lent->e->nextTrain = next->e;
return 1;
}
static int Entity_GetNoiseIndex(lua_State *L) {
lent_t *lent;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e) {
lua_pushinteger(L, -1);
return 1;
}
lua_pushinteger(L, lent->e->noise_index);
return 1;
}
static int Entity_SetNoiseIndex(lua_State *L) {
lent_t *lent;
int idx;
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e)
return 1;
idx = (int)luaL_checknumber(L, 2);
lent->e->noise_index = idx;
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},
{"FindNumber", Entity_FindNumber}, {"FindNumber", Entity_FindNumber},
{"FindBModel", Entity_FindBModel}, {"FindBModel", Entity_FindBModel},
{"GetTarget", Entity_GetTarget}, {"GetTarget", Entity_GetTarget},
{"CallSpawn", Entity_CallSpawn}, {"CallSpawn", Entity_CallSpawn},
{"DelayedCallSpawn", Entity_DelayedCallSpawn }, {"DelayedCallSpawn", Entity_DelayedCallSpawn },
{"Remove", Entity_Remove}, {"Remove", Entity_Remove},
{"RemoveUnnamedSpawns", Entity_RemoveUnnamedSpawns}, {"RemoveUnnamedSpawns", Entity_RemoveUnnamedSpawns},
{"RemoveSpawns", Entity_RemoveSpawns}, {"RemoveSpawns", Entity_RemoveSpawns},
{"RemoveType", Entity_RemoveType}, {"RemoveType", Entity_RemoveType},
{"Use", Entity_Use}, {"Use", Entity_Use},
{NULL, NULL} {NULL, NULL}
}; };
/*void dummy(gentity_t *ent) { /*void dummy(gentity_t *ent) {
ent->luaUse; ent->noise_index;
}*/ }*/
static const luaL_Reg Entity_meta[] = { static const luaL_Reg Entity_meta[] = {
{"__gc", Entity_GC}, {"__gc", Entity_GC},
{"__tostring", Entity_ToString}, {"__tostring", Entity_ToString},
{"GetNumber", Entity_GetNumber}, {"GetNumber", Entity_GetNumber},
{"IsClient", Entity_IsClient}, {"IsClient", Entity_IsClient},
{"GetClientname", Entity_GetClientName}, {"GetClientname", Entity_GetClientName},
{"Print", Entity_Print}, {"Print", Entity_Print},
{"CenterPrint", Entity_CenterPrint}, {"CenterPrint", Entity_CenterPrint},
{"GetClassname", Entity_GetClassName},
{"SetClassname", Entity_SetClassName},
{"GetTargetname", Entity_GetTargetName},
{"SetTargetname", Entity_SetTargetName},
{"Rotate", Entity_Rotate},
{"IsRocket", Entity_IsRocket}, {"GetClassname", Entity_GetClassName},
{"IsGrenade", Entity_IsGrenade}, {"SetClassname", Entity_SetClassName},
{"Teleport", Entity_Teleport},
{"SetKeyValue", Entity_SetKeyValue},
{"GetOrigin", Entity_GetOrigin},
{"SetupTrigger", Entity_SetupTrigger},
{"Lock", Entity_Lock}, {"GetTargetname", Entity_GetTargetName},
{"Unlock", Entity_Unlock}, {"SetTargetname", Entity_SetTargetName},
{"IsLocked", Entity_IsLocked},
{"GetParm", Entity_GetParm}, {"Rotate", Entity_Rotate},
{"SetParm", Entity_SetParm},
{"GetActivator", Entity_GetActivator}, {"IsRocket", Entity_IsRocket},
{"SetActivator", Entity_SetActivator}, {"IsGrenade", Entity_IsGrenade},
{"Teleport", Entity_Teleport},
{"SetKeyValue", Entity_SetKeyValue},
{"GetOrigin", Entity_GetOrigin},
{"SetupTrigger", Entity_SetupTrigger},
{"GetAngle", Entity_GetAngle}, {"Lock", Entity_Lock},
{"SetAngle", Entity_SetAngle}, {"Unlock", Entity_Unlock},
{"IsLocked", Entity_IsLocked},
{"GetApos1", Entity_GetApos1}, {"GetParm", Entity_GetParm},
{"GetApos2", Entity_GetApos2}, {"SetParm", Entity_SetParm},
{"SetApos1", Entity_SetApos1}, {"GetActivator", Entity_GetActivator},
{"SetApos2", Entity_SetApos2}, {"SetActivator", Entity_SetActivator},
{"GetBluename", Entity_GetBluename}, {"GetAngle", Entity_GetAngle},
{"SetBluename", Entity_SetBluename}, {"SetAngle", Entity_SetAngle},
{"GetBluesound", Entity_GetBluesound}, {"GetApos1", Entity_GetApos1},
{"SetBluesound", Entity_SetBluesound}, {"GetApos2", Entity_GetApos2},
{"GetBooleanstate", Entity_GetBooleanstate}, {"SetApos1", Entity_SetApos1},
{"SetBooleanstate", Entity_SetBooleanstate}, {"SetApos2", Entity_SetApos2},
{"GetClipmask", Entity_GetClipmask}, {"GetBluename", Entity_GetBluename},
{"SetClipmask", Entity_SetClipmask}, {"SetBluename", Entity_SetBluename},
{"GetCount", Entity_GetCount}, {"GetBluesound", Entity_GetBluesound},
{"SetCount", Entity_SetCount}, {"SetBluesound", Entity_SetBluesound},
{"GetDamage", Entity_GetDamage}, {"GetBooleanstate", Entity_GetBooleanstate},
{"SetDamage", Entity_SetDamage}, {"SetBooleanstate", Entity_SetBooleanstate},
{"GetDistance", Entity_GetDistance}, {"GetClipmask", Entity_GetClipmask},
{"SetDistance", Entity_SetDistance}, {"SetClipmask", Entity_SetClipmask},
{"GetEnemy", Entity_GetEnemy}, {"GetCount", Entity_GetCount},
{"SetEnemy", Entity_SetEnemy}, {"SetCount", Entity_SetCount},
{"GetEventTime", Entity_GetEventTime}, {"GetDamage", Entity_GetDamage},
{"SetEventTime", Entity_SetEventTime}, {"SetDamage", Entity_SetDamage},
{"GetFalsename", Entity_GetFalsename}, {"GetDistance", Entity_GetDistance},
{"SetFalsename", Entity_SetFalsename}, {"SetDistance", Entity_SetDistance},
{"GetFalsetarget", Entity_GetFalsetarget}, {"GetEnemy", Entity_GetEnemy},
{"SetFalsetarget", Entity_SetFalsetarget}, {"SetEnemy", Entity_SetEnemy},
{"GetFlags", Entity_GetFlags}, {"GetEventTime", Entity_GetEventTime},
{"SetFlags", Entity_SetFlags}, {"SetEventTime", Entity_SetEventTime},
{"GetFreeAfterEvent", Entity_GetFreeAfterEvent}, {"GetFalsename", Entity_GetFalsename},
{"SetFreeAfterEvent", Entity_SetFreeAfterEvent}, {"SetFalsename", Entity_SetFalsename},
{"GetFreetime", Entity_GetFreetime}, {"GetFalsetarget", Entity_GetFalsetarget},
{"SetFalsetarget", Entity_SetFalsetarget},
{"GetGreensound", Entity_GetGreensound}, {"GetFlags", Entity_GetFlags},
{"SetGreensound", Entity_SetGreensound}, {"SetFlags", Entity_SetFlags},
{"GetHealth", Entity_GetHealth}, {"GetFreeAfterEvent", Entity_GetFreeAfterEvent},
{"SetHealth", Entity_SetHealth}, {"SetFreeAfterEvent", Entity_SetFreeAfterEvent},
{"GetInUse", Entity_GetInUse}, {"GetFreetime", Entity_GetFreetime},
{"SetInUse", Entity_SetInUse},
{"GetLastEnemy", Entity_GetLastEnemy}, {"GetGreensound", Entity_GetGreensound},
{"SetLastEnemy", Entity_SetLastEnemy}, {"SetGreensound", Entity_SetGreensound},
{"GetLuaDie", Entity_GetLuaDie}, {"GetHealth", Entity_GetHealth},
{"SetLuaDie", Entity_SetLuaDie}, {"SetHealth", Entity_SetHealth},
{"GetLuaEntity", Entity_GetLuaEntity}, {"GetInUse", Entity_GetInUse},
{"SetLuaEntity", Entity_SetLuaEntity}, {"SetInUse", Entity_SetInUse},
{"GetLuaFree", Entity_GetLuaFree}, {"GetLastEnemy", Entity_GetLastEnemy},
{"SetLuaFree", Entity_SetLuaFree}, {"SetLastEnemy", Entity_SetLastEnemy},
{"GetLuaHurt", Entity_GetLuaHurt}, {"GetLuaDie", Entity_GetLuaDie},
{"SetLuaHurt", Entity_SetLuaHurt}, {"SetLuaDie", Entity_SetLuaDie},
{"GetLuaReached", Entity_GetLuaReached}, {"GetLuaEntity", Entity_GetLuaEntity},
{"SetLuaReached", Entity_SetLuaReached}, {"SetLuaEntity", Entity_SetLuaEntity},
{"GetLuaReachedAngular", Entity_GetLuaReachedAngular}, {"GetLuaFree", Entity_GetLuaFree},
{"SetLuaReachedAngular", Entity_SetLuaReachedAngular}, {"SetLuaFree", Entity_SetLuaFree},
{"GetLuaSpawn", Entity_GetLuaSpawn}, {"GetLuaHurt", Entity_GetLuaHurt},
{"SetLuaSpawn", Entity_SetLuaSpawn}, {"SetLuaHurt", Entity_SetLuaHurt},
{"GetLuaThink", Entity_GetLuaThink}, {"GetLuaReached", Entity_GetLuaReached},
{"SetLuaThink", Entity_SetLuaThink}, {"SetLuaReached", Entity_SetLuaReached},
{"GetLuaTouch", Entity_GetLuaTouch}, {"GetLuaReachedAngular", Entity_GetLuaReachedAngular},
{"SetLuaTouch", Entity_SetLuaTouch}, {"SetLuaReachedAngular", Entity_SetLuaReachedAngular},
{"GetLuaTrigger", Entity_GetLuaTrigger}, {"GetLuaSpawn", Entity_GetLuaSpawn},
{"SetLuaTrigger", Entity_SetLuaTrigger}, {"SetLuaSpawn", Entity_SetLuaSpawn},
{"GetLuaUse", Entity_GetLuaUse}, {"GetLuaThink", Entity_GetLuaThink},
{"SetLuaUse", Entity_SetLuaUse}, {"SetLuaThink", Entity_SetLuaThink},
{"GetLuaTouch", Entity_GetLuaTouch},
{"SetLuaTouch", Entity_SetLuaTouch},
{"GetLuaTrigger", Entity_GetLuaTrigger},
{"SetLuaTrigger", Entity_SetLuaTrigger},
{"GetLuaUse", Entity_GetLuaUse},
{"SetLuaUse", Entity_SetLuaUse},
{"GetMessage", Entity_GetMessage},
{"SetMessage", Entity_SetMessage},
{"GetMethodOfDeath", Entity_GetMethodOfDeath},
{"SetMethodOFDeath", Entity_SetMethodOfDeath},
{"GetModel", Entity_GetModel},
{"SetModel", Entity_SetModel},
{"GetModel2", Entity_GetModel2},
{"SetModel2", Entity_SetModel2},
{"GetMovedir", Entity_GetMovedir},
{"SetMovedir", Entity_SetMovedir},
{"GetMoverstate", Entity_GetMoverstate},
{"SetMoverstate", Entity_SetMoverstate},
{"GetN00bCount", Entity_GetN00bCount},
{"SetN00bCount", Entity_SetN00bCount},
{"GetNeverFree", Entity_GetNeverFree},
{"SetNeverFree", Entity_SetNeverFree},
{"GetNextthink", Entity_GetNexthink},
{"SetNextthink", Entity_SetNexthink},
{"GetNextTrain", Entity_GetNextTrain},
{"SetNextTrain", Entity_SetNextTrain},
{"GetNoiseIndex", Entity_GetNoiseIndex},
{"SetNoiseIndex", Entity_SetNoiseIndex},
{NULL, NULL} {NULL, NULL}
}; };

Binary file not shown.