Code:
function CheckAqueductsInOregon(iPlayer, iPolicyID)
local pPlayer = Players[iPlayer]
if (pPlayer:GetCivilizationType() == CIVILIZATION_OREGON) then
for pCity in pPlayer:Cities() do
if (iPolicyID == GameInfos.Policies.POLICY_TRADITION_FINISHER.ID) then
pCity:SetNumRealBuilding(BUILDING_AQUEDUCT, 0);
pCity:SetNumRealBuilding(BUILDING_CITY_BRIDGE, 0);
end
end
end
end
Unless you are defining CIVILIZATION_OREGON, BUILDING_AQUEDUCT, and BUILDING_CITY_BRIDGE as lua variables elsewhere in your code, your lua does not work because the game's lua system does not work off of XML tag-names. So for pPlayer:GetCivilizationType()
Code:
(pPlayer:GetCivilizationType() == CIVILIZATION_OREGON)
will always evaluate to being a false statement since pPlayer:GetCivilizationType() returns an integer value and CIVILIZATION_OREGON would be interpretted as being an undefined lua variable. Undefined lua variables are always assigned a value of "nil". "nil" can never be equal to an integer value. You want
Code:
(pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_OREGON)
GameInfoTypes.CIVILIZATION_OREGON grabs the proper integer ID # for CIVILIZATION_OREGON from the <Civilizations> table, which is what the lua method
pPlayer:GetCivilizationType() grabs for the given player (ie, the ID # from table <Civilizations> that is being used by "pPlayer").
For pCity:SetNumRealBuilding(iBuildingID, iNumberBuildings) you want
Code:
pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_AQUEDUCT, 0);
pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_CITY_BRIDGE, 1);
You need the integer '1' in the second pCity:SetNumRealBuilding(args) line in order to add the desired building to the city. '0' removes the Building, whether it was already present in the city or not.
You also need to ensure that if BUILDING_CITY_BRIDGE is defined as belonging to the BUILDINGCLASS_AQUEDUCT class of buildings, that none of the column-settings you are using within that database definition of the building will be refused by the game when BUILDING_CITY_BRIDGE is not defined as a unique replacement for BUILDINGCLASS_AQUEDUCT for CIVILIZATION_OREGON . See the link in my sig re Dummy Buildings & Building-Class Structure Issues. The issues re replacement buildings not defined as belonging to a particular civilization apply regardless of whether or not a building is a dummy.
Also, if function CheckAqueductsInOregon is hooked as a listener to PlayerAdoptPolicy, you will never get this line to be evaluated as true
Code:
if (iPolicyID == GameInfos.Policies.POLICY_TRADITION_FINISHER.ID) then
From some old documentation I had laying around:Even if it did, you'd never get the line to be evaluated as "true" since you need "GameInfo" instead of "GameInfos"
----------------------------
And as I recall (perhaps not quite correctly) the issue with the Aqueduct not being replaced with a unique replacement by the game engine had to do with the <FoodKept> column and the game looking for the building with the highest setting of <FoodKept>.