Actual Craft Time 2.0


A working version of Actual Craft Time for 2.0 ! Display actual craft times for assemblers, furnaces, rocket silo, and more.

Utilities
4 months ago
2.0
4.29K
Manufacturing

b [Fixed] Recycler has wrong calculations with speed modules

4 months ago
(updated 4 months ago)

Hi, I noticed that when adding speed modules (or beacons with speed modules) to recyclers, the calculated effects were too strong.

Examples of the recycler recycling scrap:
Recipe is 0.2 seconds, but since the recycler has a crafting speed of 0.5, it takes 0.4 seconds (2.5 items/s).
Adding a speed module mk2 (+30% speed) increases crafting speed to 0.65, making the recipe take ~0.31 seconds (3.24 items/s, as indicated by game UI)
The mod however, shows a recipe speed of 0.237 seconds (4.22 items/s), which is a ~69% increase (not nice)
Adding 2 speed modules mk 2 (+60% speed) increases crafting speed to 0.8, creating 4 items/s as indicated by game UI.
The mod however, shows a recipe speed of 0.156 seconds (6.4 items/s), which is a 156% increase.

Spotting the pattern:
1.3 * 1.3 = 1.69 --> 69% increase is just 30% increase twice
1.6 * 1.6 = 2.56 --> 156% increase is just 60% increase twice

I've tried looking through the code where this double effect is happening (but only for the recycler) but boy am I out of my depth. Hope at least this analysis is helpful.

4 months ago

Hi, I noticed that when adding speed modules (or beacons with speed modules) to recyclers, the calculated effects were too strong.

Examples of the recycler recycling scrap:
Recipe is 0.2 seconds, but since the recycler has a crafting speed of 0.5, it takes 0.4 seconds (2.5 items/s).
Adding a speed module mk2 (+30% speed) increases crafting speed to 0.65, making the recipe take ~0.31 seconds (3.24 items/s, as indicated by game UI)
The mod however, shows a recipe speed of 0.237 seconds (4.22 items/s), which is a ~69% increase (not nice)
Adding 2 speed modules mk 2 (+60% speed) increases crafting speed to 0.8, creating 4 items/s as indicated by game UI.
The mod however, shows a recipe speed of 0.156 seconds (6.4 items/s), which is a 156% increase.

Spotting the pattern:
1.3 * 1.3 = 1.69 --> 69% increase is just 30% increase twice
1.6 * 1.6 = 2.56 --> 156% increase is just 60% increase twice

I've tried looking through the code where this double effect is happening (but only for the recycler) but boy am I out of my depth. Hope at least this analysis is helpful.

Hey, thank you for your bug report. We had some trouble figuring out how to properly implement modules. We will look into it :3

4 months ago
(updated 4 months ago)

Cool! I couldn't help myself and played around with the mod code myself. I found that by adding a getRecipeFromRecycler function which checks if the machine is a recycler with if entity.name:find("recycler") then, and then simply passing an all-0-bonus "effects" object, it calculated it correctly. I just don't understand how😭

Edit: OR: in the getRecipeFromFurnace, if you replace the sec calculation with

local sec = recipe.energy / entity.crafting_speed
if not entity.name:find("recycler") then
    sec = sec / (effects.speed.bonus + 1)
end

it also seems to work. Although, that seems insane to add there, because again, I don't know why the crafting speed already contains the speed modules' speed bonus for recyclers 😭

4 months ago

Cool! I couldn't help myself and played around with the mod code myself. I found that by adding a getRecipeFromRecycler function which checks if the machine is a recycler with if entity.name:find("recycler") then, and then simply passing an all-0-bonus "effects" object, it calculated it correctly. I just don't understand how😭

Edit: OR: in the getRecipeFromFurnace, if you replace the sec calculation with
local sec = recipe.energy / entity.crafting_speed if not entity.name:find("recycler") then sec = sec / (effects.speed.bonus + 1) end
it also seems to work. Although, that seems insane to add there, because again, I don't know why the crafting speed already contains the speed modules' speed bonus for recyclers 😭

Hey, thank you for report. I used your function. Fixed in 0.7.0 :3 Best wishes.

4 months ago

Cool! Thanks!

New response