Simple (at least it should be) trait not working.

Durkle

Chieftain
Joined
Jul 29, 2017
Messages
29
Location
Jerusalem
Hey everybody, part of my custom civs trait is that it grants faith upon settling a city. Sounds simple enough, but I can't seem to figure out how to make it work. Here's the code I have right now:
Code:
local iChickasaw = GameInfoTypes.CIVILIZATION_CHICKASAW
function Kohta_Falaya_Founded(playerID, iCityX, iCityY)
    local player = Players[playerID]
     if (not player:IsAlive()) then return end
     if (not player:GetCivilizationType()==iChickasaw then return end
     local chickasawFaithPerTurn = ((player:GetTotalFaithPerTurn() + 1) * 10)
     player:ChangeFaith(chickasawFaithPerTurn)
end

GameEvents.PlayerCityFounded.Add(Kohta_Falaya_Founded)

To me it seems like this should work, but right now I don't get any faith from founding a city. What's wrong here?
 
Hey everybody, part of my custom civs trait is that it grants faith upon settling a city. Sounds simple enough, but I can't seem to figure out how to make it work. Here's the code I have right now:
Code:
local iChickasaw = GameInfoTypes.CIVILIZATION_CHICKASAW
function Kohta_Falaya_Founded(playerID, iCityX, iCityY)
    local player = Players[playerID]
     if (not player:IsAlive()) then return end
     if (not player:GetCivilizationType()==iChickasaw then return end
     local chickasawFaithPerTurn = ((player:GetTotalFaithPerTurn() + 1) * 10)
     player:ChangeFaith(chickasawFaithPerTurn)
end

GameEvents.PlayerCityFounded.Add(Kohta_Falaya_Founded)

To me it seems like this should work, but right now I don't get any faith from founding a city. What's wrong here?

There's an error on this line: if (not player:GetCivilizationType()==iChickasaw then return end. You're missing a closing ) bracket.
In Lua, brackets around an if-statement aren't necessary as well, though adding them doesn't cause problems. E.g.
Code:
if something==somethingelse then
Is the same as (in Lua)
Code:
if (something==somethingelse) then

----
The Lua.log tells you about these issues, or at least gives you a general direction as to where the problem lies.
 
There's an error on this line: if (not player:GetCivilizationType()==iChickasaw then return end. You're missing a closing ) bracket.
In Lua, brackets around an if-statement aren't necessary as well, though adding them doesn't cause problems. E.g.
Code:
if something==somethingelse then
Is the same as (in Lua)
Code:
if (something==somethingelse) then

----
The Lua.log tells you about these issues, or at least gives you a general direction as to where the problem lies.
Wow, thank you. I guess sometimes you just get silly typos like this and need someone else to point it out for you...
 
Top Bottom