Page 1 of 1

Update the type of EffectValue to be be uint16

Posted: Fri May 24, 2024 3:19 am
by bunshaman
Currently the effect value page https://lua-api.factorio.com/latest/typ ... html#bonus claims that bonus is stored as a double. This is not the case, it is actually stored as a uint16 and is reflected by trying to create a module with a bonus higher than (2^16 - 1)/2 because the bonus rolls over into the negatives.

Re: Update the type of EffectValue to be be uint16

Posted: Fri May 24, 2024 8:10 am
by boskid
No, not really.

First of all, it is not uint16 because effect values can be negative (for example productivity modules give speed penalty). Second, if it would be documented as integer then it would say that only acceptable values are integers however effect values loaded have 0.01 resolution that are equivalent of a 1% of the effect. Internally effect values are converted to int16 where a value is a percentage which gives an effective effect value range from -327.68 to 327.67.

Re: Update the type of EffectValue to be be uint16

Posted: Fri May 24, 2024 11:22 am
by curiosity
This sounds like a modding interface request, not a documentation request. But also the docs are incorrect, the value is given off to mods as 32-bit floating point. You can tell by the horrid imprecision.

Re: Update the type of EffectValue to be be uint16

Posted: Mon May 27, 2024 8:51 am
by Bilka
Thanks for noting this, I added the range given by boskid to the docs for the next release.

Re: Update the type of EffectValue to be be uint16

Posted: Fri May 31, 2024 4:21 am
by bunshaman
yeah I hadn't exactly expressed it right but yeah I guess my point was that the modding docs dont actually mention that it sneakily behaves as a int16 where the value is a percentage of that number. The way it is set up currently led me to believe I could have a effective effect value of some large number, lets say 23402 and not actually capping at the range you gave boskid.