IsHasBuilding
From Civilization Modding Wiki
Revision as of 09:31, 14 February 2012 by Killmeplease (talk | contribs) (Created page with "==Description== Returns true if a subject [Lua Game Objects/City|city] has a building with a specified ID ==Example== (from [http://forums.civfanatics.com/showthread.php?t=450146...")
Description
Returns true if a subject [Lua Game Objects/City|city] has a building with a specified ID
Example
(from Culture per Population mod)
-- add culture when wonder completed function CulturePerPop(iPlayer) local buildingID, buildingTime; local player = Players[iPlayer]; if IsValidPlayer(player) then for pCity in player:Cities() do for row in GameInfo.Building_CultureChangePerPop() do -- has wonder? buildingID = GameInfo.Buildings[row.BuildingType].ID; if pCity:IsHasBuilding(buildingID) then -- just built? buildingTime = pCity:GetBuildingOriginalTime(buildingID); if buildingTime == Game:GetGameTurnYear() then pCity:ChangeJONSCulturePerTurnFromBuildings( math.floor(pCity:GetPopulation() / row.Pop * row.Culture)); end end end end end end