kingchris20
Wisdom Seeker
Can someone let me know if something is wrong with either of these codes?
I have a building and I need this code to check for 1,000 energy. if the player has 1,000 energy or more in reserve, the building should be added to the city.
I know next to nothing of LUA, the 2nd code is from AgressiveWimp, and the first code is the same, but changed up and based on some of Ryika's LUA.
I have also tried it this way to no avail...
I have a building and I need this code to check for 1,000 energy. if the player has 1,000 energy or more in reserve, the building should be added to the city.
I know next to nothing of LUA, the 2nd code is from AgressiveWimp, and the first code is the same, but changed up and based on some of Ryika's LUA.
Code:
function CheckStargateUSAF(pPlayer)
local ActivePlayer = Players[pPlayer]
if ActivePlayer:GetCivilizationType() == GameInfoTypes["CIVILIZATION_STARGATE_USAF"] then
-- print("ZPM Activation at 1,000 Energy")
for iCity in Players[i]:Cities() do
if (ActivePlayer:GetEnergy() >= 1000) then
-- print("Activating Shield of Atlantis!)
city:SetNumRealBuilding(GameInfoTypes["BUILDING_SHIELD_OF_ATLANTIS"], 1)
else
city:SetNumRealBuilding(GameInfoTypes["BUILDING_SHIELD_OF_ATLANTIS"], 0)
end
end
end
end
GameEvents.PlayerDoTurn.Add(CheckStargateUSAF)
I have also tried it this way to no avail...
Code:
GameEvents.PlayerDoTurn.Add(
function(iPlayer)
local pPlayer = Players[iPlayer]
if not (pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_STARGATE_USAF) then return end
for pCity in pPlayer:Cities() do
if (pPlayer:GetEnergy() >= 1000) then
pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_SHIELD_OF_ATLANTIS, 1)
else
pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_SHIELD_OF_ATLANTIS, 0)
end
end
end)