Beispiel #1
0
int l_Zone_getEntitiesCount(lua_State* L)
{
	Zone* zone = getZone(L, 1);
	lua_Integer count = 0;
	const Map& map = zone->getMap();
	zone->eachTileIfExists([&count, &map](const Tile* tile)
	{
		count += map.getTileEntityCount(tile);
	});
	lua_pushinteger(L, count);
	return 1;
}
Beispiel #2
0
int l_Zone_getEntities(lua_State* L)
{
	Zone* zone = getZone(L, 1);
	lua_newtable(L);
	int index = 1;

	const Map& map = zone->getMap();
	zone->eachTileIfExists([L, &index, &map](const Tile* tile)
	{
		map.eachTileEntity(
			tile,
			[L, &index](entity::Entity* entity)
			{
				entity::lua::pushEntity(L, entity);
				lua_rawseti(L, -2, index);
				++index;
			}
		);
	});
	return 1;
}