0
0
Fork 0
mirror of https://github.com/UberGames/RPG-X2.git synced 2025-03-23 16:01:06 +00:00

Finished the update as good as I could.

Removed something from entity that is already in game.

Signed-off-by: Harry Young <hendrik.gerritzen@googlemail.com>
This commit is contained in:
Harry Young 2011-12-09 15:52:19 +01:00
parent aee590c176
commit 43d044fe4f
4 changed files with 56 additions and 123 deletions

View file

@ -22,8 +22,10 @@ static int Entity_GetTarget(lua_State * L)
return 1;
}
// entity.FindBModel(int bmodel)
// finds entity by brush model
// entity.FindBModel(integer bmodelnum)
// Returns the entity with the brush model bmodelnumber.
// This is the only failsafe way to find brush entities as the
// entity number is different when you load a map local or join a server.
static int Entity_FindBModel(lua_State *L) {
gentity_t *ent;
int bmodel;
@ -38,8 +40,8 @@ static int Entity_FindBModel(lua_State *L) {
return 1;
}
// entity.FindNumber(int num)
// finds entity by number
// entity.FindNumber(integer entnum)
// Returns the entity with the entity number entnum.
static int Entity_FindNumber(lua_State * L)
{
int entnum;
@ -56,7 +58,7 @@ static int Entity_FindNumber(lua_State * L)
}
// entity.Find(string targetname)
// finds and returns an entity by it's targetname
// Returns the first entity found that has a targetname of targetname.
static int Entity_Find(lua_State * L)
{
gentity_t *t = NULL;
@ -70,8 +72,8 @@ static int Entity_Find(lua_State * L)
return 1;
}
// entity.Use(entity targetname)
// Uses an entity.
// entity.Use(entity ent)
// Uses ent.
static int Entity_Use(lua_State * L)
{
lent_t *lent;
@ -87,8 +89,8 @@ static int Entity_Use(lua_State * L)
return 1;
}
// entity.Teleport(entity ent, entity target)
// Teleports a player to another entity
// entity.Teleport(entity client, entity target)
// Teleports client to target's position
static int Entity_Teleport(lua_State * L)
{
lent_t *lent;
@ -110,7 +112,7 @@ static int Entity_Teleport(lua_State * L)
// entity.IsRocket(entity ent)
// Checks if an entity is a rocket
// Checks if an entity is a rocket.
static int Entity_IsRocket(lua_State * L)
{
lent_t *lent;
@ -126,7 +128,7 @@ static int Entity_IsRocket(lua_State * L)
}
// entity.IsGrenade(entity ent)
// Checks if an enity is a grenade
// Checks if an entity is a grenade.
static int Entity_IsGrenade(lua_State * L)
{
lent_t *lent;
@ -141,8 +143,9 @@ static int Entity_IsGrenade(lua_State * L)
return 1;
}
// entity.Spawn(void)
// Spawn a new entity if possible
// entity.Spawn()
// Tries to spawn a new entity and returns it.
// If no new entity can be spawned nil is returned.
static int Entity_Spawn(lua_State * L)
{
gentity_t *ent;
@ -204,84 +207,6 @@ static int Entity_GetClientName(lua_State * L)
return 1;
}
static int Entity_Print(lua_State * L)
{
lent_t *lent;
int i;
char buf[MAX_STRING_CHARS];
int n = lua_gettop(L);
lent = Lua_GetEntity(L, 1);
if(!lent|| !lent->e) return 1;
if(!lent->e->client)
return luaL_error(L, "\'Print\' must be used with a client entity");
memset(buf, 0, sizeof(buf));
lua_getglobal(L, "tostring");
for(i = 2; i <= n; i++)
{
const char *s;
lua_pushvalue(L, -1);
lua_pushvalue(L, i);
lua_call(L, 1, 1);
s = lua_tostring(L, -1);
if(s == NULL)
return luaL_error(L, "\'tostring\' must return a string to \'print\'");
Q_strcat(buf, sizeof(buf), s);
lua_pop(L, 1);
}
trap_SendServerCommand(lent->e - g_entities, va("print \"%s\n\"", buf));
return 1;
}
static int Entity_CenterPrint(lua_State * L)
{
lent_t *lent;
int i;
char buf[MAX_STRING_CHARS];
int n = lua_gettop(L);
lent = Lua_GetEntity(L, 1);
if(!lent || !lent->e) return 1;
if(!lent->e->client)
return luaL_error(L, "\'CenterPrint\' must be used with a client entity");
memset(buf, 0, sizeof(buf));
lua_getglobal(L, "tostring");
for(i = 2; i <= n; i++)
{
const char *s;
lua_pushvalue(L, -1);
lua_pushvalue(L, i);
lua_call(L, 1, 1);
s = lua_tostring(L, -1);
if(s == NULL)
return luaL_error(L, "\'tostring\' must return a string to \'print\'");
Q_strcat(buf, sizeof(buf), s);
lua_pop(L, 1);
}
trap_SendServerCommand(lent->e - g_entities, va("cp \"" S_COLOR_WHITE "%s\n\"", buf));
return 1;
}
extern qboolean G_ParseField(const char *key, const char *value, gentity_t *ent);
// entity.SetKeyValue(entity ent, string key, string value)
// Sets a key of an entity to a value
@ -346,24 +271,6 @@ static int Entity_GetTargetName(lua_State * L)
return 1;
}
// entity.Rotate(entity ent, vector dir)
// Rotates an entity in the specified directions
static int Entity_Rotate(lua_State * L)
{
lent_t *lent;
vec_t *vec;
lent = Lua_GetEntity(L, 1);
vec = Lua_GetVector(L, 2);
lent->e->s.apos.trType = TR_LINEAR;
lent->e->s.apos.trDelta[0] = vec[0];
lent->e->s.apos.trDelta[1] = vec[1];
lent->e->s.apos.trDelta[2] = vec[2];
return 1;
}
static int Entity_GC(lua_State * L)
{
@ -395,8 +302,8 @@ static void ent_delay(gentity_t *ent) {
G_CallSpawn(ent);
}
// entity.DelayedCallSpawn(entity ent, int ms)
// Calls the entities spawn function delayed
// entity.DelayedCallSpawn(entity ent, integer delay)
// Calls the game logic spawn function for the class of ent after a delay of delay milliseconds.
static int Entity_DelayedCallSpawn(lua_State *L) {
lent_t *lent;
int delay;
@ -418,7 +325,7 @@ static int Entity_DelayedCallSpawn(lua_State *L) {
}
// entity.CallSpawn(entity ent)
// Calls the entities spawn function
// Calls the game logic spawn function for the class of ent.
static int Entity_CallSpawn(lua_State *L) {
lent_t *lent;
qboolean r = qfalse;
@ -445,6 +352,8 @@ static int Entity_CallSpawn(lua_State *L) {
return 1;
}
// entity.RemoveUnnamedSpawns()
// Removes all spawn points from the map, that don't have a targetname.
extern field_t fields[];
static int Entity_RemoveUnnamedSpawns(lua_State *L) {
gentity_t *ent;
@ -465,6 +374,8 @@ static int Entity_RemoveUnnamedSpawns(lua_State *L) {
return 1;
}
// entity.RemoveSpawns()
// Removes all spawn points from the map.
static int Entity_RemoveSpawns(lua_State *L) {
gentity_t *ent;
int cnt = 0, i;
@ -483,6 +394,8 @@ static int Entity_RemoveSpawns(lua_State *L) {
return 1;
}
// entity.RemoveType(string classname)
// Removes all entities of type classname from the map.
static int Entity_RemoveType(lua_State *L) {
int i, cnt = 0;
char *classname;
@ -527,9 +440,14 @@ static int Entity_Remove(lua_State *L) {
return 1;
}
// entity.SetupTrigger(entity ent, int sizex, int sizey, int sizez)
// entity.SetupTrigger(entity ent, float x, float y, float z) or
// entity.SetupTrigger(entity ent, vector size)
// Sets up some basic trigger things
// Does some setup for entities spawned by script that are to be used as trigger.
// * ent the entity
// * x length along the X-Axis
// * y length along the Y-Axis
// * z length along the Z-axis
// * Can also be stowed in a vector size
static int Entity_SetupTrigger(lua_State *L) {
lent_t *lent;
gentity_t *e;
@ -588,6 +506,8 @@ static int Entity_GetOrigin(lua_State *L) {
return 1;
}
// ent.Lock(entity ent)
// Looks the entity ent. Works with anything that can be locked (doors, turbolifts, usables, ...).
static int Entity_Lock(lua_State *L) {
lent_t *lent;
gentity_t *ent;
@ -614,6 +534,8 @@ static int Entity_Lock(lua_State *L) {
return 1;
}
// ent.Unlock(entity ent)
// Unlooks the entity ent. Works with anything that can be locked (doors, turbolifts, usables, ...).
static int Entity_Unlock(lua_State *L) {
lent_t *lent;
gentity_t *ent;

View file

@ -4,7 +4,7 @@
#ifdef G_LUA
// game.Print(string text)
// Prints a text to the game console
// Prints text to the server console
static int Game_Print(lua_State *L) {
int i;
char buf[MAX_STRING_CHARS];
@ -42,8 +42,9 @@ static int Game_Print(lua_State *L) {
return 0;
}
// game.CenterPrint(string text)
// Prints a message to the center of the screen of each client
// game.CenterPrint(integer clientNum, string text)
// Prints text to the center of the screen of the client with client number clientNum.
// If clientNum is -1 the text gets printed for all clients.
static int Game_CenterPrint(lua_State *L) {
int i;
char buf[MAX_STRING_CHARS];
@ -83,8 +84,9 @@ static int Game_CenterPrint(lua_State *L) {
return 0;
}
// game.ClientPrint
// Prints a message to the client console
// game.ClientPrint(integer clientNum, string text)
// Prints text to the clients console that has the client number clientNum.
// If clientNum is -1 the text gets printed to all clients consoles.
static int Game_ClientPrint(lua_State *L) {
int i;
char buf[MAX_STRING_CHARS];
@ -127,8 +129,9 @@ static int Game_ClientPrint(lua_State *L) {
return 0;
}
// game.MessagePrint
// Prints a message to the lower right corner of all clients screens
// game.MessagePrint(integer clientNum, string text)
// Prints text to the lower right corner of the screen of the client with client number clientNum.
// If clientNum is -1 the text gets printed for all clients.
static int Game_MessagePrint(lua_State *L) {
int i;
char buf[MAX_STRING_CHARS];
@ -167,6 +170,10 @@ static int Game_MessagePrint(lua_State *L) {
return 0;
}
// game.SetGlobal(string name, value)
// Sets a global Lua variable which is called name to value.
// Creates a new global variable if a variable of name does not exist.
// value can be of any type.
static int Game_SetGlobal(lua_State *L) {
char *name;
@ -180,6 +187,9 @@ static int Game_SetGlobal(lua_State *L) {
return 0;
}
// game.GetGlobal(string name)
// Returns the value of the global variable name.
// Returns nil if the variable does not exist.
static int Game_GetGlobal(lua_State *L) {
char *name;
@ -192,6 +202,7 @@ static int Game_GetGlobal(lua_State *L) {
return 1;
}
// Alert-Stuff... I don't know. I feel like removing this and stick to the entity spawning and setup.
// game.AlertSetup(entity ent, string greentarget, string yellowtarget, string redtarget, string bluetarget,
// string greensound, string yellowsound, string redsound, string bluesound, integer mode)
static int Game_AlertSetup(lua_State *L) {
@ -277,8 +288,8 @@ static int Game_Alert(lua_State *L) {
return 0;
}
// game.LevelTime(void)
// Returns the current level time in milli seconds
// game.LevelTime()
// Returns the current level time in milliseconds.
static int Game_Leveltime(lua_State * L)
{
lua_pushinteger(L, level.time);