Percedal / FS22_UpgradableFactories

FS22 mod that increase production chains efficiency
GNU General Public License v3.0
28 stars 8 forks source link

Large greenhouse (lettuce)- Production does not meet cycles #52

Open Tidli01 opened 1 month ago

Tidli01 commented 1 month ago

At level 2, the greenhouse produces 1424 liters of lettuce per month instead of 1651 liters. Increasing to level 3 does not give any increase, the greenhouse produces 1424 liters per month instead of 2534. At level 4, instead of 3417 liters, production is only 2870 liters of lettuce per month. On odd numbers, performance does not increase, remaining at the previous level.

Tidli01 commented 1 month ago

This problem occurs when you skip time through sleep

Tidli01 commented 1 month ago

"I am not strong in Lua and programming, but as a temporary solution, I slightly modified the function getCycleAtLvl and UpgradableFactories.updateProductionPointLevel in the UpgradableFactories file. It looks like this:"

local function getCycleAtLvl(cycle, lvl, isMonthly) -- Added argument isMonthly -- Production speed increase by its base value each level. -- A bonus of 15% of the base speed is applied per level starting at level 2. -- e.g. base cycles were 100, factory at level 3: 1003 + 1000.15(3-1) = 300 + 1000.152 = 300 + 30 = 330 lvl = tonumber(lvl) local adj = cycle lvl + cycle 0.15 (lvl - 1)

if adj < 1 then
    return adj
elseif isMonthly then
    -- Rounding for monthly calculation
    -- Done so that the value in the game interface is an integer
    return math.floor(adj)
else
    -- Increasing accuracy for other cases
    -- For accurate calculation of production output
    return math.floor(adj * 100) / 100
end

end

"After that, I added new arguments for the function UpgradableFactories.updateProductionPointLevel"

function UpgradableFactories.updateProductionPointLevel(prodpoint, lvl) prodpoint.productionLevel = lvl prodpoint.name = prodPointUFName(prodpoint.baseName, lvl)

for _, prod in pairs(prodpoint.productions) do
    prod.cyclesPerMinute = getCycleAtLvl(prod.baseCyclesPerMinute, lvl, false)
    prod.cyclesPerHour = getCycleAtLvl(prod.baseCyclesPerHour, lvl, false)
    prod.cyclesPerMonth = getCycleAtLvl(prod.baseCyclesPerMonth, lvl, true)
    -- Adding new arguments true, false
end

end