예제 #1
0
/***
Prints text to the clients console that has the client number clientNum. If clientNum is -1 the text gets printed to all clients consoles.
@function ClientPrint
@param clientNum Client number.
@param text Text to print.
*/
static int Game_ClientPrint(lua_State *L) {
	int			i;
	char		buf[MAX_STRING_CHARS];
	int			n = lua_gettop(L);
	int			clNum =  luaL_checknumber(L, 1);
	gentity_t	*player;

	memset(buf, 0, sizeof(buf));

	lua_getglobal(L, "tostring");

	LUA_DEBUG("BEGIN - game.ClientPrint");

	for(i = 1; i < n; i++) {
		const char		*s;

		lua_pushvalue(L, -1);
		lua_pushvalue(L, i);
		lua_call(L, 1, 1);
		s = lua_tostring(L, 2);

		if(s == NULL)
		{
			LUA_DEBUG("BEGIN - game.ClientPrint - no string");
			lua_pushboolean(L, qfalse);
			return 1;
		}

		Q_strcat(buf, sizeof(buf), s);

		lua_pop(L, 1);
	}

	if(clNum != -1) {
		player = &g_entities[clNum];
		if(player && player->client) {
			G_PrintfClient(player, "%s", buf);
		}
	} else {
		G_PrintfClientAll("%s", buf);
	}

	LUA_DEBUG("END - game.ClientPrint");
	lua_pushboolean(L, qtrue);
	return 1;
}
예제 #2
0
void G_LuaStatus(gentity_t * ent)
{
	int i, cnt = 0;

	for(i = 0; i < NUM_VMS; i++)
		if(lVM[i])
			cnt++;

	if(ent)
	{
		if(cnt == 0)
		{
			G_PrintfClient(ent, "Lua: no scripts loaded.");
			return;
		}
		else if(cnt == 1)
		{
			G_PrintfClient(ent, "Lua: showing lua information ( 1 module loaded )");
		}
		else
		{
			G_PrintfClient(ent, "Lua: showing lua information ( %d modules loaded )", cnt);
		}
		G_PrintfClient(ent, "%-2s %-24s", "VM","Filename");
		G_PrintfClient(ent, "-- ------------------------");
		for(i = 0; i < NUM_VMS; i++)
		{
			if(lVM[i])
			{
				G_PrintfClient(ent, "%2d %-24s", lVM[i]->id, lVM[i]->filename);
			}
		}
		G_PrintfClient(ent, "-- ------------------------");
	}
	else
	{
		if(cnt == 0)
		{
			G_Printf("Lua: no scripts loaded.\n");
			return;
		}
		else if(cnt == 1)
		{
			G_Printf("Lua: showing lua information ( 1 module loaded )\n");
		}
		else
		{
			G_Printf("Lua: showing lua information ( %d modules loaded )\n", cnt);
		}
		G_Printf("%-2s %-24s\n", "VM", "Filename");
		G_Printf("-- ------------------------\n");
		for(i = 0; i < NUM_VMS; i++)
		{
			if(lVM[i])
			{
				G_Printf("%2d %-24s\n", lVM[i]->id, lVM[i]->filename);
			}
		}
		G_Printf("-- ------------------------\n");
	}

}
예제 #3
0
/** G_LuaStatus(ent)
 * Prints information on the Lua virtual machines.
 */
void G_LuaStatus(gentity_t * ent)
{
	int             i, cnt = 0;

	for(i = 0; i < LUA_NUM_VM; i++)
		if(lVM[i])
			cnt++;

	//G_Printf("Lua API: lua_status for client %d", (ent - g_entities));

	if(ent)
	{
		if(cnt == 0)
		{
			G_PrintfClient(ent, "Lua API: no scripts loaded.");
			return;
		}
		else if(cnt == 1)
		{
			G_PrintfClient(ent, "Lua API: showing lua information ( 1 module loaded )");
		}
		else
		{
			G_PrintfClient(ent, "Lua API: showing lua information ( %d modules loaded )", cnt);
		}
		G_PrintfClient(ent, "%-2s %-24s %-40s %-24s", "VM", "Modname", "Signature", "Filename");
		G_PrintfClient(ent, "-- ------------------------ ---------------------------------------- ------------------------");
		for(i = 0; i < LUA_NUM_VM; i++)
		{
			if(lVM[i])
			{
				G_PrintfClient(ent, "%2d %-24s %-40s %-24s", lVM[i]->id, lVM[i]->mod_name, lVM[i]->mod_signature,
							   lVM[i]->file_name);
			}
		}
		G_PrintfClient(ent, "-- ------------------------ ---------------------------------------- ------------------------");
	}
	else
	{
		if(cnt == 0)
		{
			G_Printf("Lua API: no scripts loaded.\n");
			return;
		}
		else if(cnt == 1)
		{
			G_Printf("Lua API: showing lua information ( 1 module loaded )\n");
		}
		else
		{
			G_Printf("Lua API: showing lua information ( %d modules loaded )\n", cnt);
		}
		G_Printf("%-2s %-24s %-40s %-24s\n", "VM", "Modname", "Signature", "Filename");
		G_Printf("-- ------------------------ ---------------------------------------- ------------------------\n");
		for(i = 0; i < LUA_NUM_VM; i++)
		{
			if(lVM[i])
			{
				G_Printf("%2d %-24s %-40s %-24s\n", lVM[i]->id, lVM[i]->mod_name, lVM[i]->mod_signature, lVM[i]->file_name);
			}
		}
		G_Printf("-- ------------------------ ---------------------------------------- ------------------------\n");
	}

}