City ID

without knowing the player you mean ?

else:
city = player:GetCityByID()
 
Yes, the player ID is not provided by SerialEventCityCreated... :think:


Edit: Nevermind, I remembered it's possible to get the city from the plot coordinates.
PHP:
function NewCity(coordinates)
	local plot		= Map.GetPlot( coordinates.x, coordinates.y )
	local city		= plot:GetPlotCity()
	local player	  = city:GetOwner()
	local playerID	= player:GetID()

	-- stuff done here
end

LuaEvents.SerialEventCityCreated.Add( NewCity );
 
from the code in this civ5 util SerialEventCityCreated provides a few variables
Code:
function citycreated ( hex, civ, cityid, culture, continent, pop, size, fow)

	local hx, hy  = ToGridFromHex( hex.x, hex.y );
	local player = Players[ civ ];
	local city = player:GetCityByID(cityid);
	-- size best guess was graphic related
	--culture, continent, pop, fow never figured exactly what
end
Events.SerialEventCityCreated.Add ( citycreated );
shameless plug to the script i wrote, there's a lot of examples of events. no idea if they all still work with current patches (as in maybe this one got changed) but i've noticed a few threads about functions that i clearly recognized using, so there's a place to look for additional insight :)
 
each player and they usually don't start with id = 1

i don't think there is a direct variable available (array, list or table) to loop through, it has to be called via the api
 
Back
Top Bottom