Lua help - problem with getting pPlayer

bismark439

Chieftain
Joined
Aug 26, 2013
Messages
34
Code:
function GetVictoryPlayers()
	local iBekje;
	local iGogur;
	local iSilla;
	local iChina;
	-- Find out who the players are
	for iPlayer = 0, 3, 1 do

		local pPlayer = Players[iPlayer];
	--	local playername = pPlayer:GetCivilizationType()
		
		if (pPlayer:GetCivilizationType() == GameInfoTypes["CIVILIZATION_BAEKJE"]) then
			iBekje = iPlayer;
		elseif (pPlayer:GetCivilizationType() == GameInfoTypes["CIVILIZATION_SILLA"]) then
			iSilla = iPlayer;
		elseif (pPlayer:GetCivilizationType() == GameInfoTypes["CIVILIZATION_GOGURYEO"]) then
			iGogur = iPlayer;
		elseif (pPlayer:GetCivilizationType() == GameInfoTypes["CIVILIZATION_CHINA"]) then
			iChina = iPlayer;
		end
	end

	
	
	return iBekje, iGogur, iSilla, iChina;
end

This code gets iPlayer values based on their CivType.

then the code below is inserted in the same .lua file.

Code:
function TestVictory()

local iBekje, iGogur, iSilla, iChina = GetVictoryPlayers();
-- Find out who controls all the cities

local pPlayer = Players[iChina]
	local ownBeijing = pPlayer:GetStartingPlot();
		local pPlot = Map.GetPlot(ownBeijing.X, ownBeijing.Y);
		local pCity = pPlot:GetPlotCity();
		

end

This code gets starting plot and the city built on it (so i can use it to find out who the owner is)

However, Lua.log file shows
\LuaSystem/CivsAlive.lua:122: attempt to index local 'pPlayer' (a nil value)

what is wrong with this?!?!:confused::confused::confused::confused::confused:
 
Back
Top Bottom