LUA from Mod not working with VP

ripple01

Emperor
Joined
Mar 7, 2006
Messages
1,254
Location
New York City
Hello all,

I'm in the process of trying to adapt Tomatekh's Sumer Civ to be usable with Vox Populi. I'm running into an issue where the LUA for the UA (1 extra pop in newly founded cities, 2 extra pop if adjacent to a river) is not working for some reason. The UA works fine with Vanilla BNW but it is just not firing when running VP and no other mods. Here is the relevant LUA: could VP have made some changes to make this not fire? I've tried to look in the logs but didn't see anything relevant. Any help would be greatly appreciated!

Code:
GameEvents.PlayerCityFounded.Add(
function(iPlayer, iCityX, iCityY)
    local pPlayer = Players[iPlayer];
    local pTeam = pPlayer:GetTeam();
    local pPlot = Map.GetPlot(iCityX, iCityY);
    local pCity = pPlot:GetPlotCity();
    if (pPlayer:IsAlive()) then
        if (pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_AKKADIAN_MOD) then
            if not isBNW then
                if ((Teams[pTeam]:GetCurrentEra()) >= 2) then
                    pCity:ChangePopulation(2, true);
                else
                    pCity:ChangePopulation(1, true);
                end
            elseif isBNW then
                local pPlot = pCity:Plot();
                if pPlot:IsRiver() then
                    pCity:ChangePopulation(2, true);
                elseif not pPlot:IsRiver() then
                    pCity:ChangePopulation(1, true);
                end
            end
        end
    end
end)
 
Oops, forgot to copy that line from the top of the file.

Code:
local isBNW = (GameInfoTypes.UNITCOMBAT_SUBMARINE ~= nil)

As far as I can tell, VP doesn't remove UNITCOMBAT_SUBMARINE, so I don't think that is the issue, but I am rusty at programming (and new to LUA) so I could be wrong.
 
Last edited:
uhhh
Code:
CIVILIZATION_AKKADIAN_MOD
Tomatekh's Sumer Civ
??

I haven't tried debugging it(maybe because you haven't uploaded all your mod files... that could lead to an error), but if all hope seems lost you could install a dummy event on a city foundation that allows players to choose for the city to produce +1 population or +2 population if near a river. (Yes the AI understands which is more if you added a stronger flavor to it)
 
Last edited:
uhhh
Code:
CIVILIZATION_AKKADIAN_MOD

??

Sumer is indeed CIVILIZATION_AKKADIAN_MOD internally; IIRC, Tomatekh was originally going to do Akkad but in the middle of development decided to make Sumer instead. Lots of his civs do something similar - the Goths are CIVILIZATION_VISIGOTHS_MOD, the Kuikuro are CIVILIZATION_XINGU_MOD, the Garamantes are CIVILIZATION_ANCIENT_LIBYA_MOD, etc.
 
Thanks all for your replies. As Kilisz says, the civ is defined as CIVILIZATION_AKKADIAN_MOD in the XML, so that is not the issue. I took the LUA file and removed all of the isBNW references (since VP requires BNW anyway, it is just extraneous) and it is still not working. Here is the block of code after removing the isBNW section; does this still look correct?

Code:
GameEvents.PlayerCityFounded.Add(
function(iPlayer, iCityX, iCityY)
    local pPlayer = Players[iPlayer];
    local pTeam = pPlayer:GetTeam();
    local pPlot = Map.GetPlot(iCityX, iCityY);
    local pCity = pPlot:GetPlotCity();
    if (pPlayer:IsAlive()) then
        if (pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_AKKADIAN_MOD) then
            local pPlot = pCity:Plot();
            if pPlot:IsRiver() then
                pCity:ChangePopulation(2, true);
            elseif not pPlot:IsRiver() then
                pCity:ChangePopulation(1, true);
            end
        end
    end
end)

Enginseer, thanks for that suggestion; I'll keep it in mind if I can't figure it out.

In Civ4, the Python logs were very helpful in sorting out errors, but I'm not seeing anything in the logs that would help debug this issue. Is there a more detailed LUA log available anywhere that I may not be looking?
 
Thanks all for your replies. As Kilisz says, the civ is defined as CIVILIZATION_AKKADIAN_MOD in the XML, so that is not the issue. I took the LUA file and removed all of the isBNW references (since VP requires BNW anyway, it is just extraneous) and it is still not working. Here is the block of code after removing the isBNW section; does this still look correct?

Code:
GameEvents.PlayerCityFounded.Add(
function(iPlayer, iCityX, iCityY)
    local pPlayer = Players[iPlayer];
    local pTeam = pPlayer:GetTeam();
    local pPlot = Map.GetPlot(iCityX, iCityY);
    local pCity = pPlot:GetPlotCity();
    if (pPlayer:IsAlive()) then
        if (pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_AKKADIAN_MOD) then
            local pPlot = pCity:Plot();
            if pPlot:IsRiver() then
                pCity:ChangePopulation(2, true);
            elseif not pPlot:IsRiver() then
                pCity:ChangePopulation(1, true);
            end
        end
    end
end)

Enginseer, thanks for that suggestion; I'll keep it in mind if I can't figure it out.

In Civ4, the Python logs were very helpful in sorting out errors, but I'm not seeing anything in the logs that would help debug this issue. Is there a more detailed LUA log available anywhere that I may not be looking?

Lua.log is what we got. Add print statements and they'll display in the firetuner.
 
Top Bottom