Modmod of Gedemon's Cultural Diffusion - is this proper Lua?

3335d

CCtP Player
Joined
Jun 15, 2012
Messages
642
I was mucking around with Gedemon's Cultural Diffusion (v11) and changed some of the code so that cultural diffusion would account for factors in addition to culture. I would like to know if the Lua I used was proper, and whether my modifications would result in any change in-game if playtested.


Modifications to CultureFunctions.lua:
Code:
	-- 3335d code begins here
	local cityGoldProduction = city:GetGoldPerTurn()
	local cityScienceProduction = city:GetSciencePerTurn()
	local cityFaithProduction = city:GetFaithPerTurn()
	local cityHammersPerTurn = city:GetProductionPerTurn()
	-- 3335d code ends here
	<snip>
		-- 3335d code begins here
		value = (population + cityCultureProduction*buildingCultureBonus + cityGoldProduction*buildingGoldBonus + cityScienceProduction*buildingScienceBonus + cityFaithProduction*buildingFaithBonus + cityHammersProduction*buildingProductionBonus) * math.sqrt(culture.Value)
		-- 3335d code ends here
Modifications to CultureDefines.lua.
Code:
--
-- 3335d code begins here
-- Benefits and malus(es)? for each yield aspect of political control. Setting a negative value for the ...BonusX variables will make it a malus.
--
cityIsHasInsertBuildingNameHere1 = city:IsHasBuilding(GameInfo.Buildings["BUILDING_INSERT_BUILDING_NAME_HERE_1"].ID)
if cityIsHasInsertBuildingNameHere
	buildingCultureBonus1 = 50
	buildingGoldBonus1 = 50
	buildingScienceBonus1 = 50
	buildingFaithBonus1 = 50
	buildingProductionBonus1 = 50
end
cityIsHasInsertBuildingNameHere2 = city:IsHasBuilding(GameInfo.Buildings["BUILDING_INSERT_BUILDING_NAME_HERE_2"].ID)
if cityIsHasInsertBuildingNameHere
	buildingCultureBonus2 = 50
	buildingGoldBonus2 = 50
	buildingScienceBonus2 = 50
	buildingFaithBonus2 = 50
	buildingProductionBonus2 = 50
end
buildingCultureBonus = (buildingCultureBonus1 + buildingCultureBonus2)/100
buildingGoldBonus = (buildingGoldBonus1 + buildingGoldBonus2)/100
buildingScienceBonus = (buildingScienceBonus1 + buildingScienceBonus2)/100
buildingFaithBonus = (buildingFaithBonus1 + buildingFaithBonus2)/100
buildingProductionBonus = (buildingProductionBonus1 + buildingProductionBonus2)/100
-- 3335d code ends here

Note that BUILDING_INSERT_NAME_HERE_1, etc. do not actually exist in the XML, they are merely placeholders until I can actually write a mod with some flavor and balance :).

The value variable defines the base rate of cultural diffusion, modified by terrain-based maluses and benefits.
 
Well, you forgot "then" twice in the second snippet (after "if").
Aside of that you would have to check how the order of magnitude of value will compare with the original value to be sure the diffusion speed will stay in range.

Now the best way is to try it yourself. Modify your ini files and run Firetuner, you will see whether there are errors.
 
Well, you forgot "then" twice in the second snippet (after "if").
Aside of that you would have to check how the order of magnitude of value will compare with the original value to be sure the diffusion speed will stay in range.

Now the best way is to try it yourself. Modify your ini files and run Firetuner, you will see whether there are errors.

Thanks Don. I can change the diffusion speed range by means of nicely-placed values in CultureDefines.lua.
 
Back
Top Bottom