Code:
Player:GetCapitalCity();
City:IsCapital();
Do any of these code gets the original capital or wherever the capital is, the player has?
Both these methods work directly on/for a player's current capital.
City:IsOriginalCapital() will tell you whether or not a particular city ever was a player's original capital.
---------------------------------------------------------------------------
Code:
pCapitalCity = pPlayer:GetCapitalCity()
Will give 'pPlayer's current capital city in the "pointer" form so that you can use the variable
pCapitalCity within methods such as
pCapitalCity:IsOriginalCapital(), which would give you "true/false" as to whether that current capital city was the player's original capital city.
----------------------------------------------------------------------------
Gives the "true/false" as to whether any city you are currently "examing" via some lua loop, code, or event-hook, is the current capital city for a player.
-----------------------------------------------------------------------------
The following two methods are equivalent for placing the "pointer data" for the player's capital city into variable
pCapitalCity:
Code:
local pPlayer = Players[iPlayer]
local pCapitalCity = pPlayer:GetCapitalCity()
vs
Code:
local pPlayer = Players[iPlayer]
local pCapitalCity
for pCity in pPlayer:Cities() do
if pCity:IsCapital() then
pCapitalCity = pCity
break
end
end
Both methods will give you "nil" for variable
pCapitalCity if the player has not founded their capital city yet. So if running, for example, a PlayerDoTurn event, you should probably also include code for
pPlayer:IsFoundedFirstCity() which gives "true/false" for whether the player has founded their 1st city yet.
---------------------------------------------------------------------
You can also use the 1st more-direct method of getting the player's capital city and do so even more directly as in:
Code:
local pCapitalCity = Players[iPlayer]:GetCapitalCity()