Better Air Filtering

by JoeyDP

An overhaul of the air filtering mod by Schorty. Includes complex air filtering steps to remove pollution.

Content
2 years ago
0.17 - 1.1
9.53K
Environment

b [Resolved] amount absorbed being different spam

4 years ago

Hello, I'm curious why this happens on my stress test.

https://imgur.com/a/WNthWbT

4 years ago
(updated 4 years ago)

Is the pollution absorbed too low that it gets rounded down to 0, and it throws an error? ( update rate @ 5 )
This doesn't happen @ 120 updates per sec, so it's fine. I'm just curious about what causes the error.

4 years ago

I'd have to look into it, but your explanation seems likely. Could you send me the map?

4 years ago

Sorry i already deleted the test files. Ill try reproducing how it happened

4 years ago

https://www.dropbox.com/sh/3b8zspxdqj0ftnk/AACplF47L59fvFILVFH9InvKa?dl=0

managed to reproduce it, but i cant get it to spam like the test earlier, only managed to get 1 error

https://imgur.com/a/n1Ew7Sy

3 years ago

I also have this issue, though thankfully not at the spam level. I get a message every few minutes or so, on average.

3 years ago

It's likely due to an underflow error. It first absorbs a very small amount of pollution and then divides this amount over a bunch of machines. I assume that after the division the value is rounded to zero in the float format, which would explain the difference and the reported error.

Unfortunately, I don't have time to fix it at the moment. I'll keep you posted when I get to it.

–Joey

2 years ago
(updated 2 years ago)

Any way we could just get a toggle switch to not display the error? I get this all the time. Trying to keep pollution low, because this is my factory: https://i.imgur.com/spzOirA.png

2 years ago

The new version should make this much less common: https://mods.factorio.com/mod/better-air-filtering/changelog
- relative tolerance added for checking (when a lot of pollution is handled, larger mistakes are tolerated).
- floating point optimization to make underflow less common.

Let me know if your issue is fixed with this!

2 years ago
(updated 2 years ago)

The new version should make this much less common:

i just got it since today with THIS new version... (just after update)

2 years ago

i just got it since today with THIS new version... (just after update)

Let's hope it's at least fixed for the other user then "-_-.

Could you send me a screenshot of the messages? I need to know how the values differ.

2 years ago
(updated 2 years ago)

I'm still getting it too:

https://i.imgur.com/RPAk6FA.png

Edit: oh my god how do I make it stop

https://i.imgur.com/3IcEaWK.png

2 years ago
(updated 2 years ago)

Hi,

since the equation in your script is:


local tol = math.max(0.01 * toAbsorb, 0.001)
if math.abs(toAbsorb - totalInsertedAmount) > tol then
    game.print("Error with inserting pollution in air filter machine. Different amounts absorbed/inserted: " .. toAbsorb .. " absorbed and " .. totalInsertedAmount .. " inserted.")
end

it will ALWAYS print, if inserted == 0

so i suggest to change that to:

if math.abs(toAbsorb - totalInsertedAmount) > tol then
    if totalInsertedAmount > 0 then
        game.print("Error with inserting pollution in air filter machine. Different amounts absorbed/inserted: " .. toAbsorb .. " absorbed and " .. totalInsertedAmount .. " inserted.")
    end
end

2 years ago

Thanks for the suggestion! I don't think it always prints if totalInsertedAmount == 0 since I also added the absolute tolerance of 0.001. In the latest update I changed it to a one sided error checking, because I suspect the difference is caused by the Factorio engine not allowing small values of fluid to be inserted.

Let me know if this works (if you haven't given up on the mod by now that is).

–Joey

2 years ago
(updated 2 years ago)

will check later, thanks for update.

"math.abs(toAbsorb - totalInsertedAmount) > tol" is always TRUE, if totalInsertedAmount equals zero, while toAbsorb is greater than zero but smaller than 0.1.

local tol = math.max(0.01 * toAbsorb, 0.001) just sets thi MINIMUM of tol to 0.001
so checking those numbers on the printouts, i.e. 0.011666~ the calculation was


if (0.011666 - 0) > 0.001 then...

so it ALWAYS prints, when (0.01*toAbsorb) is SMALLER than 0.001, which means on all cases where toAbsorb < 0.1 while totalInsertedAmount is 0 (donno why this might happen, but the prints show all "... and 0 inserted")

2 years ago

Not going to give up on it, you seem committed to fixing it and it's pretty integral to my savefile at this point, not sure what would happen if I removed it. I was getting a bunch of spam, though, came back here to check on an update, downloaded the most recent update, and reloaded my game. It appears to have stopped for now, I'll update you if it comes back.

2 years ago

Just an update - haven't seen this message since. Thanks for the fix, love the mod!

New response