kingchris20
Wisdom Seeker
Need some help again.
This code works perfectly (Thanks Ryika & AgressiveWimp)! But, only if the user loads the mod, backs out to the main menu so that "configuring game data" shows, and them reloads into the mod.
My question is - Is there anyway to get this thing loaded and recognizing my new XMLs without the user having to back out to the main menu first?
My assumption is because the LUA references new XMLs. New XMLs get loaded when the mod is loaded, but I guess the LUA loads first and since the XMLs are loaded afterwards, the LUA doesn't recognize the new XMLs.
print(GameInfoTypes["CIVILIZATION_STARGATE_USAF"]) - this section of the code returns "nil" unless the user backs out to the main menu first..... if the user backs out to the main menu first, and reloads the mod, it returns the sponsor number as it should and works perfectly fine.
This code works perfectly (Thanks Ryika & AgressiveWimp)! But, only if the user loads the mod, backs out to the main menu so that "configuring game data" shows, and them reloads into the mod.
Code:
function CheckStargateUSAF(pPlayer)
local ActivePlayer = Players[pPlayer]
print(ActivePlayer:GetCivilizationType())
print(GameInfoTypes["CIVILIZATION_STARGATE_USAF"])
if ActivePlayer:GetCivilizationType() == GameInfoTypes["CIVILIZATION_STARGATE_USAF"] then
print ("ZPM Activation at 1,000 Energy")
for iCity in Players[pPlayer]:Cities() do
if (ActivePlayer:GetEnergy() >= 1000) then
print ("Activating Shield of Atlantis!")
iCity :SetNumRealBuilding(GameInfoTypes["BUILDING_SHIELD_OF_ATLANTIS"], 1)
else
iCity :SetNumRealBuilding(GameInfoTypes["BUILDING_SHIELD_OF_ATLANTIS"], 0)
end
end
end
end
GameEvents.PlayerDoTurn.Add(CheckStargateUSAF)
My question is - Is there anyway to get this thing loaded and recognizing my new XMLs without the user having to back out to the main menu first?
My assumption is because the LUA references new XMLs. New XMLs get loaded when the mod is loaded, but I guess the LUA loads first and since the XMLs are loaded afterwards, the LUA doesn't recognize the new XMLs.
print(GameInfoTypes["CIVILIZATION_STARGATE_USAF"]) - this section of the code returns "nil" unless the user backs out to the main menu first..... if the user backs out to the main menu first, and reloads the mod, it returns the sponsor number as it should and works perfectly fine.