Update the type of EffectValue to be be uint16

Post Reply
bunshaman
Manual Inserter
Manual Inserter
Posts: 2
Joined: Fri May 24, 2024 3:14 am
Contact:

Update the type of EffectValue to be be uint16

Post 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.

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2263
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Update the type of EffectValue to be be uint16

Post 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.

curiosity
Filter Inserter
Filter Inserter
Posts: 352
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: Update the type of EffectValue to be be uint16

Post 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.

Bilka
Factorio Staff
Factorio Staff
Posts: 3170
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Update the type of EffectValue to be be uint16

Post by Bilka »

Thanks for noting this, I added the range given by boskid to the docs for the next release.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

bunshaman
Manual Inserter
Manual Inserter
Posts: 2
Joined: Fri May 24, 2024 3:14 am
Contact:

Re: Update the type of EffectValue to be be uint16

Post 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.

Post Reply

Return to “Resolved Requests”