Help needed - Lua script stopped running

aschulak

Chieftain
Joined
Dec 11, 2010
Messages
92
Having fun getting used to Civ 6 waiting for the modding tools to come out to start porting some of my old Civ 5 mods... Wrote a quick script to keep my treasury always stocked with Gold. Was working great and then one day I noticed it wasn't running anymore and didn't show any output in the tuner log console. Any thoughts?

Code:
function OnPlayerTurnActivated(player, bIsFirstTime)
    print("on player turn activated");
    print(player);
    print(Game.GetLocalPlayer());
    if (player == Game.GetLocalPlayer()) then
        print("in my code");
        local pPlayer = Players[player];
        if pPlayer:IsHuman() then
            if (pPlayer:GetTreasury():GetGoldBalance() < 900000) then
                pPlayer:GetTreasury():ChangeGoldBalance(100000);
                print("changed gold treasury");
            end
        end
    end
end

function PreserveGold()
    print("preserve gold");
    Events.PlayerTurnActivated.Add(OnPlayerTurnActivated)
end

print("Initting...");
PreserveGold();
print("Initialized.");
 
Did you load a saved game? Lua files set as Gameplay Scripts in the modinfo file do not reload when a save is loaded.

Yes, that is how it is added. What is the proper way to add it? Thank you!
 
Top Bottom