Detecting how many unit are alive for each civilization.

Enginseer

Salientia of the Community Patch
Supporter
Joined
Nov 7, 2012
Messages
3,674
Location
Somewhere in California
Hi, I'm trying to make an event where how many units you have will grant you bonus food in every non-coastal cities, but culture in every coastal cities.

Code:
function nextturn(iPlayer)
local pPlayer = Players[iPlayer]
local units = 0
for pUnit in pPlayer:Units() do
units = units + 1
end
foodcost(pPlayer, units)
end

function foodcost(pPlayer, units)
for pCity in pPlayer:Cities() do
if not pCity:IsCoastal() then
pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_FOOD_ADDER"], units)
elseif pCity:IsCoastal() then
pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_CULTURE_ADDER"], units)
end
end
end
GameEvents.PlayerDoTurn.Add(nextturn)

However, I'm unsure what minWaterSize is in the function of City:IsCoastal(int minWaterSize)

Could anyone help clarify what that is?
 
From what I can understand of the DLL source, IsCoastal() doesn't actually need an argument at all - and testing in the Firetuner's console, it works the same with 0, 1, 2, or 3 arguments. I'm not sure why the Modiki has that minWaterSize thing there.
 
From what I can understand of the DLL source, IsCoastal() doesn't actually need an argument at all - and testing in the Firetuner's console, it works the same with 0, 1, 2, or 3 arguments. I'm not sure why the Modiki has that minWaterSize thing there.

I've always assumed that minWaterSize was how many ocean tiles does the city have to justify that it's a coastal city. Oh well, if it doesn't matter I guess putting in 2 should be fine. Thanks!
 
Code:
local iCultureAdderBuilding = GameInfoTypes["BUILDING_CULTURE_ADDER"]
local iFoodAdderBuilding = GameInfoTypes["BUILDING_FOOD_ADDER"]

function nextturn(iPlayer)
	local pPlayer = Players[iPlayer]
	local iNumUnits = pPlayer:GetNumUnits()
	for pCity in pPlayer:Cities() do
		if pCity:IsCoastal() then
			pCity:SetNumRealBuilding(iCultureAdderBuilding, iNumUnits)
		else
			pCity:SetNumRealBuilding(iFoodAdderBuilding, iNumUnits)
		end
	end
end
GameEvents.PlayerDoTurn.Add(nextturn)
 
Back
Top Bottom