Lua is messing up the cost of future social policies

Uighur_Caesar

Comandante en Jefe
Joined
Mar 14, 2015
Messages
1,227
Location
Florida
Ok so I've been trying to make the UA for my Gaddafi mod, one part of it being "Gold gifts give 5% more influence for every 2 policies." So I made two functions to do this. Here's the first one:

Spoiler :
Code:
function GaddafiSetup(playerID, policyID)
local player = Players[playerID]
	if (player:IsAlive() and player:GetCivilizationType() == gaddafiID) then
	local capital = player:GetCapitalCity()
	local num = capital:GetNumRealBuilding(GameInfoTypes.BUILDING_UC_GADDAFI_UA)
		capital:SetNumRealBuilding(GameInfoTypes.BUILDING_UC_GADDAFI_UA, num + 1)
end
end

if isGaddafiActive then
GameEvents.PlayerAdoptPolicy.Add(GaddafiSetup)
GameEvents.PlayerAdoptPolicyBranch.Add(GaddafiSetup)
end

And the second:

Spoiler :
Code:
function GaddafiGoldGifts(playerID)
local player = Players[playerID]
	if (player:IsAlive() and player:GetCivilizationType() == gaddafiID) then
	local capital = player:GetCapitalCity()
	local policies = capital:GetNumRealBuilding(GameInfoTypes.BUILDING_UC_GADDAFI_UA)
	local quotient = policies / 2
	if policies % 2 == 0 and quotient > 0 then
	local newPolicy = GameInfoTypes["POLICY_UC_GADDAFI_GOLD_" .. tostring(quotient)];
	player:SetNumFreePolicies(1)
	player:SetNumFreePolicies(0)
	player:SetHasPolicy(newPolicy, true)
	end
	end
end

if isGaddafiActive then
GameEvents.PlayerDoTurn.Add(GaddafiGoldGifts)
end

The first one puts dummy buildings in your capital whenever you enact a policy and the second checks if there's an even number of those buildings in your capital and then give the policies that provide 5% influence per gold gift each.

Both of those are working fine, but I've found that something this messes up the calculation of your next policy's cost. After enacting either your third or fourth policy the cost of future policies starts changing. At first, it'll display the correct amount of culture needed, say 105, but once your culture passes 60-80, the cost of the policy suddenly drops to 60 and after selecting the policy remains at 60 as well. After enacting your next policy, the cost goes back up to 105, but this cycle repeats over and over again.

I have absolutely no idea what's going on so if someone could help that would be greatly appreciated. I'm not sure if this will be usefu but here;s the lua log:

Spoiler :
Code:
[620683.828] Initializing Lua 5.1.4
[620776.828] InstalledPanel: Refreshing Mods
[620776.828] InstalledPanel: GetModBrowserListings()
[620776.921] InstalledPanel: Refreshing Mods
[620776.921] InstalledPanel: GetModBrowserListings()
[620782.890] InstalledPanel: Refreshing Mods
[620782.890] InstalledPanel: GetModBrowserListings()
[620800.500] InstalledPanel: Refreshing Mods
[620800.500] InstalledPanel: GetModBrowserListings()
[620803.109] InstalledPanel: Refreshing Mods
[620803.109] InstalledPanel: GetModBrowserListings()
[620851.843] Map Script: Generating Map
[620851.843] Map Script: Generating Plot Types (Lua Continents) ...
[620851.843] Map Script: Setting Plot Types (MapGenerator.Lua)
[620851.859] Map Script: Setting Plot Types (MapGenerator.Lua)
[620851.875] Map Script: Setting Plot Types (MapGenerator.Lua)
[620851.890] Map Script: Setting Plot Types (MapGenerator.Lua)
[620851.906] Map Script: Setting coasts and oceans (MapGenerator.Lua)
[620851.921] Map Script: Expanding coasts (MapGenerator.Lua)
[620851.921] Map Script: Generating Terrain (Lua Continents) ...
[620851.921] Map Script: Setting Terrain Types (MapGenerator.Lua)
[620851.921] Map Script: Map Generation - Adding Rivers
[620851.921] Map Script: Map Generation - Adding Lakes
[620851.921] Map Script: Adding Features (Lua Continents) ...
[620851.937] Map Script: Creating start plot database.
[620851.953] Map Script: Dividing the map in to Regions.
[620851.953] Map Script: Map Generation - Dividing the map in to Regions
[620851.953] Map Script: -
[620851.953] Map Script: Civs:	2
[620851.953] Map Script: City States:	4
[620851.953] Map Script: * * * * * * * * * *
[620851.953] Map Script: Area ID 1095 has fertility of 4
[620851.953] Map Script: Area ID 1096 has fertility of 111
[620851.953] Map Script: Area ID 1094 has fertility of 225
[620851.953] Map Script: Area ID 1097 has fertility of 503
[620851.953] Map Script: * * * * * * * * * *
[620851.953] Map Script: Interim Table ID 1 has fertility of 4
[620851.953] Map Script: Interim Table ID 2 has fertility of 111
[620851.953] Map Script: Interim Table ID 3 has fertility of 225
[620851.953] Map Script: Interim Table ID 4 has fertility of 503
[620851.953] Map Script: * * * * * * * * * *
[620851.953] Map Script: -
[620851.953] Map Script: --- Continental Division, Initial Readout ---
[620851.953] Map Script: -
[620851.953] Map Script: - Global Fertility:	843
[620851.953] Map Script: - Total Land Plots:	227
[620851.953] Map Script: - Total Areas:	4
[620851.953] Map Script: - Relevant Areas:	2
[620851.953] Map Script: -
[620851.953] Map Script: * * * * * * * * * *
[620851.953] Map Script: Area ID 1097 has fertility of 503
[620851.953] Map Script: Area ID 1094 has fertility of 225
[620851.953] Map Script: * * * * * * * * * *
[620851.953] Map Script: - - Searching landmasses in order to place Civ #	1
[620851.953] Map Script: -
[620851.953] Map Script: - Found new candidate landmass with Area ID#:	1097	 with fertility of 	503
[620851.953] Map Script: Civ #	1	has been assigned to Area#	1097
[620851.953] Map Script: -
[620851.953] Map Script: - - Searching landmasses in order to place Civ #	2
[620851.953] Map Script: -
[620851.953] Map Script: - Found new candidate landmass with Area ID#:	1097	 with fertility of 	251.5
[620851.953] Map Script: Civ #	2	has been assigned to Area#	1097
[620851.953] Map Script: -
[620851.953] Map Script: -
[620851.953] Map Script: --- End of Initial Readout ---
[620851.953] Map Script: -
[620851.953] Map Script: *** Number of Civs per Landmass - Table Readout ***
[620851.953] Map Script: --------------------------------------------------
[620851.953] Map Script: Table printout for table ID:	table: 12C3AE40
[620851.953] Map Script: Table index:	1	Table entry:	2
[620851.953] Map Script: Table index:	2	Table entry:	0
[620851.953] Map Script: - - - - - - - - - - - - - - - - - - - - - - - - - -
[620851.953] Map Script: --- End of Civs per Landmass readout ***
[620851.953] Map Script: -
[620851.953] Map Script: -
[620851.953] Map Script: -
[620851.953] Map Script: - Region #: 	1
[620851.953] Map Script: - Civs on this landmass: 	2
[620851.953] Map Script: - Area ID#: 	1097
[620851.953] Map Script: - Fertility: 	503
[620851.953] Map Script: - Plot Count: 	208
[620851.953] Map Script: -
[620851.953] Map Script: DivideIntoRegions: Divide in to Halves selected.
[620851.953] Map Script: Dividing along horizontal line between rows: 	15	-	16
[620851.953] Map Script: -
[620851.953] Map Script: Removed Dead Rows, West: 	1	 East: 	0
[620851.953] Map Script: Removed Dead Rows, South: 	0	 North: 	0
[620851.953] Map Script: -
[620851.953] Map Script: Incoming values: 	25	6	13	10
[620851.953] Map Script: Outgoing values: 	26	6	12	10
[620851.953] Map Script: -
[620851.953] Map Script: Size of incoming fertility table: 	130
[620851.953] Map Script: Size of outgoing fertility table: 	120
[620851.953] Map Script: -
[620851.953] Map Script: ---------------------------------------------
[620851.953] Map Script: Defined location of Start Region #	1
[620851.953] Map Script: ---------------------------------------------
[620851.953] Map Script: -
[620851.953] Map Script: -
[620851.953] Map Script: ---------------------------------------------
[620851.953] Map Script: Defined location of Start Region #	2
[620851.953] Map Script: ---------------------------------------------
[620851.953] Map Script: -
[620851.953] Map Script: -
[620851.953] Map Script: Data for Start Region #	1
[620851.953] Map Script: WestX:  	26
[620851.953] Map Script: SouthY: 	6
[620851.953] Map Script: Width:  	12
[620851.953] Map Script: Height: 	10
[620851.953] Map Script: AreaID: 	1097
[620851.953] Map Script: Fertility:	280
[620851.953] Map Script: Plots:  	120
[620851.953] Map Script: Fert/Plot:	2.3333333333333
[620851.953] Map Script: -
[620851.953] Map Script: -
[620851.953] Map Script: Data for Start Region #	2
[620851.953] Map Script: WestX:  	25
[620851.953] Map Script: SouthY: 	16
[620851.953] Map Script: Width:  	13
[620851.953] Map Script: Height: 	6
[620851.953] Map Script: AreaID: 	1097
[620851.953] Map Script: Fertility:	223
[620851.953] Map Script: Plots:  	78
[620851.953] Map Script: Fert/Plot:	2.8589743589744
[620851.953] Map Script: -
[620851.953] Map Script: Choosing start locations for civilizations.
[620851.953] Map Script: Map Generation - Choosing Start Locations for Civilizations
[620851.953] Map Script: Normalizing start locations and assigning them to Players.
[620851.953] Map Script: Player	0	of Civ Type	CIVILIZATION_UC_LIBYA
[620851.953] Map Script: Player	1	of Civ Type	CIVILIZATION_POLAND
[620851.953] Map Script: Civs with Coastal Bias:	0
[620851.953] Map Script: Civs with River Bias:	0
[620851.953] Map Script: Civs with Region Priority:	2
[620851.953] Map Script: Civs with Region Avoid:	0
[620851.953] Map Script: -
[620851.953] Map Script: Placing Natural Wonders.
[620852.000] Map Script: -
[620852.000] Map Script: -
[620852.000] Map Script: --- Number of Candidate Plots on the map for Natural Wonders ---
[620852.000] Map Script: -
[620852.000] Map Script: -	27	candidates for	FEATURE_CRATER
[620852.000] Map Script: -	1	candidates for	FEATURE_FUJI
[620852.000] Map Script: -	0	candidates for	FEATURE_MESA
[620852.000] Map Script: -	53	candidates for	FEATURE_REEF
[620852.000] Map Script: -	0	candidates for	FEATURE_VOLCANO
[620852.000] Map Script: -	47	candidates for	FEATURE_GIBRALTAR
[620852.000] Map Script: -	1	candidates for	FEATURE_GEYSER
[620852.000] Map Script: -	1	candidates for	FEATURE_FOUNTAIN_YOUTH
[620852.000] Map Script: -	22	candidates for	FEATURE_POTOSI
[620852.000] Map Script: -	7	candidates for	FEATURE_EL_DORADO
[620852.000] Map Script: -	42	candidates for	FEATURE_SRI_PADA
[620852.000] Map Script: -	0	candidates for	FEATURE_MT_SINAI
[620852.000] Map Script: -	10	candidates for	FEATURE_MT_KAILASH
[620852.000] Map Script: -	0	candidates for	FEATURE_ULURU
[620852.000] Map Script: -	2	candidates for	FEATURE_LAKE_VICTORIA
[620852.000] Map Script: -	2	candidates for	FEATURE_KILIMANJARO
[620852.000] Map Script: -	16	candidates for	FEATURE_SOLOMONS_MINES
[620852.000] Map Script: -
[620852.000] Map Script: --- End of candidates readout for Natural Wonders ---
[620852.000] Map Script: -
[620852.015] Map Script: -- Placed all Natural Wonders --
[620852.015] Map Script: -
[620852.015] Map Script: -
[620852.015] Map Script: Placing Resources and City States.
[620852.015] Map Script: Map Generation - Assigning Luxury Resource Distribution
[620852.015] Map Script: -
[620852.015] Map Script: Region#	1	 of type 	3	 has been assigned Luxury ID#	21
[620852.015] Map Script: -
[620852.015] Map Script: Region#	2	 of type 	8	 has been assigned Luxury ID#	22
[620852.015] Map Script: Luxury ID#	21	rejected by City States as already belonging to Regions.
[620852.015] Map Script: Luxury ID#	22	rejected by City States as already belonging to Regions.
[620852.015] Map Script: --- Luxury Assignment Table ---
[620852.015] Map Script: -
[620852.015] Map Script: - - Assigned to Regions - -
[620852.015] Map Script: Region#	1	has Luxury type	21
[620852.015] Map Script: Region#	2	has Luxury type	22
[620852.015] Map Script: -
[620852.015] Map Script: - - Assigned to City States - -
[620852.015] Map Script: Luxury type	16
[620852.015] Map Script: Luxury type	33
[620852.015] Map Script: Luxury type	25
[620852.015] Map Script: -
[620852.015] Map Script: - - Assigned to Random - -
[620852.015] Map Script: Luxury type	14
[620852.015] Map Script: Luxury type	20
[620852.015] Map Script: Luxury type	31
[620852.015] Map Script: Luxury type	32
[620852.015] Map Script: -
[620852.015] Map Script: - - Luxuries handled via Special Case - -
[620852.015] Map Script: Luxury type	18
[620852.015] Map Script: -
[620852.015] Map Script: - - Disabled - -
[620852.015] Map Script: Luxury type	19
[620852.015] Map Script: Luxury type	41
[620852.015] Map Script: Luxury type	23
[620852.015] Map Script: Luxury type	34
[620852.015] Map Script: Luxury type	26
[620852.015] Map Script: Luxury type	13
[620852.015] Map Script: Luxury type	15
[620852.015] Map Script: Luxury type	27
[620852.015] Map Script: Luxury type	24
[620852.015] Map Script: Luxury type	30
[620852.015] Map Script: Luxury type	17
[620852.015] Map Script: - - - - - - - - - - - - - - - -
[620852.015] Map Script: Map Generation - Placing City States
[620852.015] Map Script: Map Generation - Choosing sites for City States
[620852.015] Map Script: All city states assigned.
[620852.015] Map Script: Map Generation - Placing Luxuries
[620852.015] Map Script: -
[620852.015] Map Script: Attempting to place Luxury#	21	at start plot	33	12	in Region#	1
[620852.015] Map Script: -
[620852.015] Map Script: Attempting to place Luxury#	22	at start plot	27	18	in Region#	2
[620852.015] Map Script: -
[620852.015] Map Script: -
[620852.015] Map Script: -Assigned Luxury Type	25	to City State#	1
[620852.015] Map Script: -
[620852.015] Map Script: -
[620852.015] Map Script: -Assigned Luxury Type	25	to City State#	2
[620852.015] Map Script: -
[620852.015] Map Script: -
[620852.015] Map Script: -Assigned Luxury Type	20	to City State#	3
[620852.015] Map Script: -
[620852.015] Map Script: -
[620852.015] Map Script: -Assigned Luxury Type	16	to City State#	4
[620852.015] Map Script: -
[620852.015] Map Script: - - -
[620852.015] Map Script: Attempting to place regional luxury #	21	in Region#	1
[620852.015] Map Script: -
[620852.015] Map Script: - - -
[620852.015] Map Script: Attempting to place regional luxury #	22	in Region#	2
[620852.015] Map Script: * *
[620852.015] Map Script: * iNumTypesRandom = 	4
[620852.015] Map Script: * *
[620852.015] Map Script: iNumRandomLuxTarget = 9. Just putting in 3 of each random.
[620852.015] Map Script: -
[620852.015] Map Script: Random Luxury Target Number:	3
[620852.015] Map Script: Random Luxury Target Placed:	3
[620852.015] Map Script: -
[620852.015] Map Script: -
[620852.015] Map Script: Random Luxury Target Number:	3
[620852.015] Map Script: Random Luxury Target Placed:	3
[620852.015] Map Script: -
[620852.015] Map Script: -
[620852.015] Map Script: Random Luxury Target Number:	3
[620852.015] Map Script: Random Luxury Target Placed:	0
[620852.015] Map Script: -
[620852.015] Map Script: -
[620852.015] Map Script: Random Luxury Target Number:	3
[620852.015] Map Script: Random Luxury Target Placed:	3
[620852.015] Map Script: -
[620852.015] Map Script: -
[620852.015] Map Script: --- Eligible Types List for Second Luxury in Region#	1	---
[620852.015] Map Script: - Found eligible luxury type:	18
[620852.015] Map Script: --- End of Eligible Types list for Second Luxury in Region#	1	---
[620852.015] Map Script: -
[620852.015] Map Script: Placed Second Luxury type of ID#	18	for start located at Plot	33	12	 in Region#	1
[620852.015] Map Script: -
[620852.015] Map Script: --- Eligible Types List for Second Luxury in Region#	2	---
[620852.015] Map Script: - Found eligible luxury type:	18
[620852.015] Map Script: --- End of Eligible Types list for Second Luxury in Region#	2	---
[620852.015] Map Script: -
[620852.015] Map Script: Placed Second Luxury type of ID#	20	for start located at Plot	27	18	 in Region#	2
[620852.015] Map Script: Failed to place	2	units of Marble.
[620852.015] Map Script: Map Generation - Placing Strategics
[620852.015] Map Script: Map Generation - Placing Bonuses
[620852.015] Map Script: Map Generation - Normalize City State Locations
[620852.015] Map Script: -
[620852.015] Map Script: --- Table of Results, New Start Finder ---
[620852.015] Map Script: -
[620852.015] Map Script: Region#	1	 has start plot at: 	33	12	with Fertility Rating of 	177
[620852.015] Map Script: -
[620852.015] Map Script: Region#	2	 has start plot at: 	27	18	with Fertility Rating of 	145
[620852.015] Map Script: -
[620852.015] Map Script: --- End of Start Finder Results Table ---
[620852.015] Map Script: -
[620852.015] Map Script: -
[620852.015] Map Script: --- Table of Final Results, City State Placements ---
[620852.015] Map Script: -
[620852.015] Map Script: - City State	1	in Region	1	is located at Plot	27	8
[620852.015] Map Script: - City State	2	in Region	2	is located at Plot	35	19
[620852.015] Map Script: - City State	3	in Region	-1	is located at Plot	15	12
[620852.015] Map Script: - City State	4	in Region	-1	is located at Plot	6	12
[620852.015] Map Script: -
[620852.015] Map Script: - - - - -
[620852.015] Map Script: -
[620852.015] Map Script: --- Table of Final Results, Resource Distribution ---
[620852.015] Map Script: -
[620852.015] Map Script: - LUXURY Resources -
[620852.015] Map Script: - Whale...: 	0
[620852.015] Map Script: - Pearls..: 	3
[620852.015] Map Script: - Gold....: 	0
[620852.015] Map Script: - Silver..: 	1
[620852.015] Map Script: - Gems....: 	0
[620852.015] Map Script: - Marble..: 	1
[620852.015] Map Script: - Ivory...: 	0
[620852.015] Map Script: - Fur.....: 	5
[620852.015] Map Script: - Dye.....: 	3
[620852.015] Map Script: - Spices..: 	3
[620852.015] Map Script: - Silk....: 	0
[620852.015] Map Script: - Sugar...: 	0
[620852.015] Map Script: - Cotton..: 	2
[620852.015] Map Script: - Wine....: 	0
[620852.015] Map Script: - Incense.: 	0
[620852.015] Map Script: - Expansion LUXURY Resources -
[620852.015] Map Script: - Copper..: 	0
[620852.015] Map Script: - Salt....: 	0
[620852.015] Map Script: - Citrus..: 	0
[620852.015] Map Script: - Truffles: 	0
[620852.015] Map Script: - Crab....: 	3
[620852.015] Map Script: - Cocoa...: 	0
[620852.015] Map Script: -
[620852.015] Map Script: + TOTAL.Lux: 	28
[620852.015] Map Script: -
[620852.015] Map Script: - STRATEGIC Resources -
[620852.015] Map Script: - Iron....: 	12
[620852.015] Map Script: - Horse...: 	10
[620852.015] Map Script: - Coal....: 	24
[620852.015] Map Script: - Oil.....: 	43
[620852.015] Map Script: - Aluminum: 	19
[620852.015] Map Script: - Uranium.: 	6
[620852.015] Map Script: -
[620852.015] Map Script: - BONUS Resources -
[620852.015] Map Script: - Cow.....: 	3
[620852.015] Map Script: - Wheat...: 	3
[620852.015] Map Script: - Sheep...: 	5
[620852.015] Map Script: - Deer....: 	6
[620852.015] Map Script: - Banana..: 	2
[620852.015] Map Script: - Fish....: 	23
[620852.015] Map Script: - Stone...: 	5
[620852.015] Map Script: - Bison...: 	2
[620852.015] Map Script: -
[620852.015] Map Script: -----------------------------------------------------
[620852.015] Map Script: -------------------------------
[620852.015] Map Script: Map Generation - Adding Goodies
[620852.031] Map Script: -------------------------------
[620852.031] Map Script: Determining continents for art purposes (MapGenerator.Lua)
[620854.515] CivilopediaScreen: SetSelectedCategory(12)
[620854.515] CivilopediaScreen: CivilopediaCategory[CategoryTerrain].DisplayList
[620854.531] CivilopediaScreen: SetSelectedCategory(1)
[620854.531] CivilopediaScreen: CivilopediaCategory[CategoryHomePage].DisplayList
[620854.546] YieldIconManager: This is the modded YieldIconManager from 'DLL - Various Mod Components'
[620854.562] CityBannerManager: This is the modded CityStateStatusHelper from CBP
[620854.671] DiploList: This is the modded CityStateStatusHelper from CBP
[620854.671] SimpleDiploTrade: This is the modded TradeLogic from CBP
[620854.750] Tutorial: Loaded Additional Tutorial checks - Assets\DLC\Expansion2\Tutorial\Lua\TutorialInclude_Expansion2.lua
[620854.750] Tutorial: Loaded Additional Tutorial checks - Assets\DLC\Expansion\Tutorial\lua\TutorialInclude_Expansion1.lua
[620855.187] GenericPopup: Loaded Popup - Assets\DLC\Expansion2\UI\InGame\PopupsGeneric\ConfirmImprovementRebuildPopup.lua
[620855.187] GenericPopup: Loaded Popup - Assets\DLC\Expansion2\UI\InGame\PopupsGeneric\DeclareWarMovePopup.lua
[620855.187] GenericPopup: Loaded Popup - Assets\DLC\Expansion2\UI\InGame\PopupsGeneric\PuppetCityPopup.lua
[620855.187] GenericPopup: Loaded Popup - Assets\DLC\Expansion2\UI\InGame\PopupsGeneric\DeclareWarPlunderTradeRoutePopup.lua
[620855.187] GenericPopup: Loaded Popup - Assets\DLC\Expansion2\UI\InGame\PopupsGeneric\DeclareWarRangeStrikePopup.lua
[620855.187] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\ConfirmImprovementRebuildPopup.lua
[620855.187] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\NetworkKickedPopup.lua
[620855.187] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\CityPlotManagementPopup.lua
[620855.187] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\ConfirmCommandPopup.lua
[620855.187] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\MinorCivEnterTerritoryPopup.lua
[620855.187] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\LiberateMinorPopup.lua
[620855.187] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\ReturnCivilianPopup.lua
[620855.187] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\AnnexCityPopup.lua
[620855.187] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\DeclareWarMovePopup.lua
[620855.187] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\BarbarianRansomPopup.lua
[620855.187] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\ConfirmGiftPopup.lua
[620855.187] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\ConfirmCityTaskPopup.lua
[620855.187] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\PuppetCityPopup.lua
[620855.187] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\DeclareWarRangeStrikePopup.lua
[620855.187] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\ConfirmPolicyBranchPopup.lua
[620855.187] GenericPopup: Loaded Popup - Assets\UI\InGame\PopupsGeneric\MinorCivGoldPopup.lua
[620855.187] DeclareWarPopup: This is the modded DeclareWarPopup from CP
[620855.250] CityStateGreetingPopup: This is the modded CityStateStatusHelper from CBP
[620855.265] CityStateDiploPopup: This is the modded CityStateStatusHelper from CBP
[620855.296] EconomicGeneralInfo: Total Units - 2
[620855.296] EconomicGeneralInfo: Maint Free Units - 0
[620855.296] EconomicGeneralInfo: Paid Units - 2
[620855.296] EconomicGeneralInfo: Total Units - 2
[620855.296] EconomicGeneralInfo: Maint Free Units - 0
[620855.296] EconomicGeneralInfo: Paid Units - 2
[620855.312] DiploCurrentDeals: This is the modded TradeLogic from CBP
[620855.328] DiploRelationships: This is the modded CityStateStatusHelper from CBP
[620855.343] DiploGlobalRelationships: This is the modded DiploGlobalRelationships from CP
[620855.687] ChoosePantheonPopup: 31
[620855.687] ChoosePantheonPopup: 963
[620855.687] ChoosePantheonPopup: 994
[620855.703] EspionageOverview: This is the modded EspionageOverview from CBP
[620855.703] EspionageOverview: This is the modded CityStateStatusHelper from CBP
[620855.734] ProductionPopup: This is the 'CP Production Mod Replacement.'
[620855.750] ChooseIdeologyPopup: 31
[620855.750] ChooseIdeologyPopup: 963
[620855.750] ChooseIdeologyPopup: 994
[620855.765] ChooseInternationalTradeRoutePopup: This is the modded TradeRouteHelpers from CBP
[620855.765] CultureOverview: This is the modded CultureOverview from CBP
[620855.765] CultureOverview: Non-Wonder Great Work buildings
[620855.765] CultureOverview: 145:BUILDINGCLASS_LIBRARY/BUILDING_ROYAL_LIBRARY: 1x GW / CIVILIZATION_ASSYRIA (2,2)
[620855.765] CultureOverview: 121:BUILDINGCLASS_AMPHITHEATER/BUILDING_AMPHITHEATER: 1x GW / Generic (4,2)
[620855.765] CultureOverview: 26:BUILDINGCLASS_THEATRE/BUILDING_THEATRE: 1x GW / Generic (7,7)
[620855.765] CultureOverview: 30:BUILDINGCLASS_OPERA_HOUSE/BUILDING_OPERA_HOUSE: 1x GW / Generic (7,3)
[620855.765] CultureOverview: 116:BUILDINGCLASS_OPERA_HOUSE/BUILDING_CEILIDH_HALL: 1x GW / CIVILIZATION_CELTS (7,3)
[620855.765] CultureOverview: 193:BUILDINGCLASS_EE_GALLERY/BUILDING_EE_GALLERY: 1x GW / Generic (8,3)
[620855.765] CultureOverview: 31:BUILDINGCLASS_MUSEUM/BUILDING_MUSEUM: 2x GW+T / Generic (10,2)
[620855.765] CultureOverview: 32:BUILDINGCLASS_BROADCAST_TOWER/BUILDING_BROADCAST_TOWER: 1x GW / Generic (13,2)
[620855.765] CultureOverview: 137:BUILDINGCLASS_CATHEDRAL/BUILDING_CATHEDRAL: 1x GW / Generic (no tech)
[620855.796] TradeRouteOverview: This is the modded TradeRouteHelpers from CBP
[620855.906] IGE_Controller_All: ****************************************************************
[620855.906] IGE_Controller_All: Starting...
[620855.937] IGE_Overlay: loaded
[620855.937] IGE_CityBanner: loaded
[620855.937] IGE_MiniMap: loaded
[620855.953] IGE_TabsBar: IGE_TabsBar
[620855.953] IGE_ActivePlayerSelection: IGE_ActivePlayerSelection
[620855.968] IGE_RiversElement: IGE_RiversElement
[620855.984] IGE_TerrainPanel: IGE_TerrainPanel
[620856.000] IGE_CitiesPanel: IGE_CitiesPanel
[620856.000] IGE_UnitsPanel: IGE_UnitsPanel
[620856.015] IGE_PlayersPanel: IGE_PlayersPanel
[620856.015] IGE_TechsPanel: IGE_TechsPanel
[620856.031] IGE_PoliciesPanel: IGE_PoliciesPanel
[620856.046] IGE_ConfirmPopup: IGE_ConfirmPopup
[620856.062] IGE_Window: IGE_Window
[620856.062] IGE_Window: IGE_ShareGlobalAndOptions
[620856.062] IGE_Window: IGE_SharingGlobalAndOptions, IGE=...
[620856.062] IGE_Window: IGE loaded
[620856.062] BuildingResourcePerEra: loaded
[620856.062] BuildingYieldFromCityStates: loaded
[620856.078] CityInfoStack: loaded
[620856.078] EnactDescisionsPopup: Loading TableSaverLoader.lua...
[620856.078] EnactDescisionsPopup: Loading TSL Serializer Client...
[620856.078] EnactDescisionsPopup: TSL Serializer Client Version: 3
[620856.078] EnactDescisionsPopup: Loading TSL Serializer Core...
[620856.078] EnactDescisionsPopup: TSL Serializer Core Version: 3
[620856.078] EnactDescisionsPopup: LuaEvents for TSL Master not yet active. Enabling...
[620856.078] EnactDescisionsPopup: TSL Serializer Master activation completed.
[620856.078] EnactDescisionsPopup: Core TSL Serializer components for version 3 loaded successfully.
[620856.078] EnactDescisionsPopup: TSL Master is active, retrieving ID...
[620856.078] EnactDescisionsPopup: Index is currently 1
[620856.078] EnactDescisionsPopup: TSL Master assigning index of 1 to ID request.
[620856.078] EnactDescisionsPopup: Received ID of 1 from TSL Master.
[620856.078] EnactDescisionsPopup: Registering table 'EventsDecisions_Decisions' for use with TSLSerializer...
[620856.078] EnactDescisionsPopup: TSL Serializer version 3 loaded successfully.
[620856.078] EnactDescisionsPopup: loaded
[620856.078] EnactDescisionsPopup: Core Decisions: loaded
[620856.093] EnactDescisionsPopup: Civ Specific Decisions: loaded
[620856.125] EnactDescisionsPopup: Religious Decisions: loaded
[620856.125] EnactDescisionsPopup: JFD's Russia (Alexander I) Decisions: loaded
[620856.125] EnactDescisionsPopup: 
[620856.125] EnactDescisionsPopup: --=======================================================================================================================
[620856.125] EnactDescisionsPopup: Refresh list
[620856.125] EnactDescisionsPopup: Processing Decisions
[620856.125] EnactDescisionsPopup: 
[620856.125] EnactDescisionsPopup: Hold the Great Sejm	false	false	nil
[620856.125] EnactDescisionsPopup: Commission an Illustrated Holy Book	nil	nil	nil
[620856.125] EnactDescisionsPopup: Promote the Arts	false	false	nil
[620856.140] EnactDescisionsPopup: Nationalise the Utilities	true	false	nil
[620856.140] EnactDescisionsPopup: Initiate Tax Reforms	false	false	nil
[620856.140] EnactDescisionsPopup: Hold a Holy Festival	nil	nil	nil
[620856.140] EnactDescisionsPopup: Establish the Main Crown School	false	false	nil
[620856.140] EnactDescisionsPopup: Codify Laws	true	false	nil
[620856.140] EnactDescisionsPopup: Set Up a Universities Funding Council	true	false	nil
[620856.140] EnactDescisionsPopup: 	nil	nil	nil
[620856.140] EnactDescisionsPopup: Formalize Scales, Weights and Measures	true	false	nil
[620856.140] EnactDescisionsPopup: Request the Services of a Great Person	false	false	nil
[620856.140] EnactDescisionsPopup: 
[620856.140] EnactDescisionsPopup: Processing Generated Decisions
[620856.140] EnactDescisionsPopup: 
[620856.140] EnactDescisionsPopup: 
[620856.140] EnactDescisionsPopup: Sort by Type
[620856.140] EnactDescisionsPopup: End sort
[620856.140] EnactDescisionsPopup: Populating screen
[620856.140] EnactDescisionsPopup: End populate
[620856.140] EnactDescisionsPopup: Calculating size and anchoring
[620856.140] EnactDescisionsPopup: Refresh list end
 
  1. The mod is always better than snippets of code from within it
  2. The second chunk of code is going to execute the section here:
    Code:
    if policies % 2 == 0 and quotient > 0 then
    	local newPolicy = GameInfoTypes["POLICY_UC_GADDAFI_GOLD_" .. tostring(quotient)];
    	[color="red"]player:SetNumFreePolicies(1)
    	player:SetNumFreePolicies(0)
    	player:SetHasPolicy(newPolicy, true)[/color]
    end
    across multiple turns and will attempt to 're-give' the extra free policy and the policy already given across those multiple turns. This is bound to cause the problem you are seeing because of this, I would think. See several issues discussed in this thread: http://forums.civfanatics.com/showthread.php?t=546742
  3. added in edit: try adding a check for Player:HasPolicy(PolicyType) as a wrapper to the code I quoted in red.
    Code:
    if policies % 2 == 0 and quotient > 0 then
    	local newPolicy = GameInfoTypes["POLICY_UC_GADDAFI_GOLD_" .. tostring(quotient)];
    	if not player:HasPolicy(newPolicy) then
    		[color="red"]player:SetNumFreePolicies(1)
    		player:SetNumFreePolicies(0)
    		player:SetHasPolicy(newPolicy, true)[/color]
    	end
    end
 
Top Bottom