IsHasBuilding: Difference between revisions
From Civilization Modding Wiki
Jump to navigationJump to search
Killmeplease (talk | contribs) No edit summary |
Killmeplease (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
==Description== | ==Description== | ||
pCity:IsHasBuilding(buildingID) | '''pCity:IsHasBuilding(buildingID)''' | ||
Returns true if a subject [[Lua Game Objects/City|city]] has a building with a specified ID | Returns true if a subject [[Lua Game Objects/City|city]] has a building with a specified ID | ||
Line 8: | Line 8: | ||
'''function''' CulturePerPop(iPlayer) | '''function''' CulturePerPop(iPlayer) | ||
'''local''' buildingID, buildingTime; | '''local''' buildingID, buildingTime; | ||
'''local''' | '''local''' pPlayer = [[Players]][iPlayer]; | ||
'''if''' IsValidPlayer( | '''if''' IsValidPlayer(pPlayer) '''then''' | ||
'''for''' pCity '''in''' | '''for''' pCity '''in''' pPlayer:[[Cities]]() '''do''' | ||
'''for''' row '''in''' [[GameInfo]].Building_CultureChangePerPop() '''do''' | '''for''' row '''in''' [[GameInfo]].Building_CultureChangePerPop() '''do''' | ||
-- has wonder? | -- has wonder? |
Revision as of 09:36, 14 February 2012
Description
pCity:IsHasBuilding(buildingID)
Returns true if a subject 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 pPlayer = Players[iPlayer]; if IsValidPlayer(pPlayer) then for pCity in pPlayer: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