Thalassicus
Bytes and Nibblers
Okay, so these functions don't match their time estimates (in cities not building settlers).
Core API
Custom Formula
The API function is returning higher numbers than the custom formula:
Does anyone have ideas for what I've done wrong for the formula?
Core API
Code:
city:GetUnitProductionTurnsLeft( unitID )
Custom Formula
Code:
function ModdedProdFoodOffset(city)
local modFoodDifference = 0
if city:IsFoodProduction() and city:IsCapital() then
modFoodDifference = ModdedFoodDifferenceTimes100(city) / 100 - city:FoodDifferenceTimes100() / 100
end
return modFoodDifference
end
function ModdedGetCurrentProductionDifferenceTimes100(city, bIgnoreFood, bOverflow)
return city:GetCurrentProductionDifferenceTimes100(bIgnoreFood, bOverflow) + ModdedProdFoodOffset(city)*100
end
function ModdedGetProductionTurnsLeft(city, bIgnoreFood, bOverflow)
return math.ceil((city:GetProductionNeeded() - city:GetProduction()) / (ModdedGetCurrentProductionDifferenceTimes100(city, bIgnoreFood, bOverflow) / 100))
end
The API function is returning higher numbers than the custom formula:
- GetUnitProductionTurnsLeft
- (GetProductionNeeded - GetProduction) / GetCurrentProductionDifference
Does anyone have ideas for what I've done wrong for the formula?