Int can't seem to drop below 0 for unknown reason

I think it’s because (delta * component_depletion_rate) will be a float, and you’re substracting that from an int.
For example if (delta * component_depletion_rate) is 0.1:
1 - 0.1 = 0.9 which will be 0 as an int, so you started with 1 and after substracting you have 0, so what you’d expect.
But
0 - 0.1 = -0.1 which will be still 0 as an int, not -1.

The easiest fix would be to make component_A_amount a float, if that works.

2 Likes