Fix for -10% and +10% buttons in station's lobby#5628
Fix for -10% and +10% buttons in station's lobby#5628sturnclaw merged 1 commit intopioneerspacesim:masterfrom
Conversation
Fix for this issue pioneerspacesim#5585
|
Looking good Just change
to
and it will auto-close the issue when we merge this code. |
|
@impaktor Done |
|
Upon futher testing, I can say that my solution is not good either.
In the original code, it would be a little different:
So, if there are no fractions in the goods, I don't think this can be correctly counted without them. That's what I think, at least. Also, in this line:
I forgot to add minus to |
|
@Max5377 I suggest you start a new branch & PR fixing the minus, and any other relevant issue as you've described. |
|
@impaktor I will definitely fix the minus part. As for the other thing, I don't know how to fix that, without fractional parts in the goods. |
Fixes #5585
The problem was with this line in
refuelInternalTankindata/pigui/modules/station-view/01-lobby.lua:station:AddCommodityStock(Commodities.hydrogen, -math.ceil(mass))math.ceilis rounding number up, so if this number is negative(ex. -2.3) it will be rounded to -2 because it is nearest value that greater or equal to -2.3. So the solution is to change above mentioned line to:local commodityChangeAmount = mass < 0 and math.floor(mass) or math.ceil(mass) station:AddCommodityStock(Commodities.hydrogen, commodityChangeAmount)Accepted answer by Guffa(albeit it's for javascript, but works the same way)