I've been trying to create a lua script to manage a civilization's UA and I can't figure out what I've done wrong. I figure it has to be something wrong with how I'm hooking into the game because nothing is printing to firetuner at all.
I omitted the rest of the script because I can't think of how it could have broken anything. It's also possible that the problem is with how I added the script to the content tab of modbuddy, because I had problems with that in making a different script.
Code:
function checkHappiness(iPlayer)
print("Running happiness check");
local pPlayer = Players[iPlayer];
local pCiv = pPlayer.GetCivilizationType();
civilianUnits = {GameInfoTypes["UNIT_WORKER"], GameInfoTypes["UNIT_SETTLER"]}
greatUnits = {GameInfoTypes["UNIT_ARTIST"], GameInfoTypes["UNIT_SCIENTIST"], GameInfoTypes["UNIT_MERCHANT"], GameInfoTypes["UNIT_ENGINEER"], GameInfoTypes["UNIT_GREAT_GENERAL"], GameInfoTypes["UNIT_GREAT_ADMIRAL"], GameInfoTypes["UNIT_MUSICIAN"], GameInfoTypes["UNIT_WRITER"]};
legendarySpawn = false;
greatSpawn = false;
goodSpawn = false;
mehSpawn = false;
local netHappiness = pPlayer:GetHappiness() - pPlayer:GetUnhappiness();
if (pCiv == GameInfoTypes.CIVILIZATION_ESPON) then
print("Espon happiness is: " .. netHappiness);
if (netHappiness >= 40) then
legendarySpawn = true;
elseif (netHappiness >= 20 and netHappiness < 40) then
greatSpawn = true;
elseif (netHappiness >= 10 and netHappiness < 20) then
goodSpawn = true;
else if (netHappiness > 0 and netHappiness < 10) then
mehSpawn = true;
end
end
if (legendarySpawn or greatSpawn or goodSpawn or mehSpawn) then
spawnUnit(pPlayer)
end
end
GameEvents.PlayerDoTurn.Add(checkHappiness);
I omitted the rest of the script because I can't think of how it could have broken anything. It's also possible that the problem is with how I added the script to the content tab of modbuddy, because I had problems with that in making a different script.