Bazaar developer reference

CvLuaPlayer::lGetPlayerColors(lua_State *)

Defined in
Lua/CvLuaPlayer.cpp, line 7304
Class
CvLuaPlayer
Hook name
CivHooks::CvLuaPlayer_lGetPlayerColors

Hooks

static bool BeforeCvLuaPlayer_lGetPlayerColors(lua_State* L, int& result);static void AfterCvLuaPlayer_lGetPlayerColors(lua_State* L, int& result);static int ReplaceCvLuaPlayer_lGetPlayerColors(int (*original)(lua_State*), lua_State* L);CivRegisterBefore<CivHooks::CvLuaPlayer_lGetPlayerColors>(host, &BeforeCvLuaPlayer_lGetPlayerColors);CivRegisterAfter<CivHooks::CvLuaPlayer_lGetPlayerColors>(host, &AfterCvLuaPlayer_lGetPlayerColors);CivRegisterReplace<CivHooks::CvLuaPlayer_lGetPlayerColors>(host, &ReplaceCvLuaPlayer_lGetPlayerColors);

Code

7303//primaryColor, secondaryColor  getPlayerColors();7304int CvLuaPlayer::lGetPlayerColors(lua_State* L)7305{7306	CvPlayerAI* pkPlayer = GetInstance(L);7307	const PlayerColorTypes eColor = CvPreGame::playerColor(pkPlayer->GetID());73087309	CvPlayerColorInfo* pkPlayerColor = GC.GetPlayerColorInfo(eColor);73107311	if(pkPlayerColor == NULL)7312	{7313		luaL_error(L, "Could not find player color at row %d", eColor);7314		return 0;7315	}73167317	const ColorTypes ePrimaryColor	 = (ColorTypes)pkPlayerColor->GetColorTypePrimary();7318	const ColorTypes eSecondaryColor = (ColorTypes)pkPlayerColor->GetColorTypeSecondary();73197320	CvColorInfo* pkPrimaryColor = GC.GetColorInfo(ePrimaryColor);7321	if(pkPrimaryColor == NULL)7322	{7323		luaL_error(L, "Could not find primary color at row %d", ePrimaryColor);7324		return 0;7325	}7326	const CvColorA& kPrimaryColor = pkPrimaryColor->GetColor();73277328	CvColorInfo* pkSecondaryColor = GC.GetColorInfo(eSecondaryColor);7329	if(pkSecondaryColor == NULL)7330	{7331		luaL_error(L, "Could not find secondary color at row %d", eSecondaryColor);7332		return 0;7333	}7334	const CvColorA& kSecondaryColor = pkSecondaryColor->GetColor();73357336	//Now export colors7337	lua_createtable(L, 0, 4);7338	lua_pushnumber(L, kPrimaryColor.r);7339	lua_setfield(L, -2, "x");7340	lua_pushnumber(L, kPrimaryColor.g);7341	lua_setfield(L, -2, "y");7342	lua_pushnumber(L, kPrimaryColor.b);7343	lua_setfield(L, -2, "z");7344	lua_pushnumber(L, kPrimaryColor.a);7345	lua_setfield(L, -2, "w");73467347	lua_createtable(L, 0, 4);7348	lua_pushnumber(L, kSecondaryColor.r);7349	lua_setfield(L, -2, "x");7350	lua_pushnumber(L, kSecondaryColor.g);7351	lua_setfield(L, -2, "y");7352	lua_pushnumber(L, kSecondaryColor.b);7353	lua_setfield(L, -2, "z");7354	lua_pushnumber(L, kSecondaryColor.a);7355	lua_setfield(L, -2, "w");73567357	return 2;7358}

Calls

Called by