Closed tuirgin closed 2 years ago
I propose to support up to .001 per slot, and work from that precision. Then just do a "millislot" if you will, or 1/1000th of a slot, so multiply the slots per by 1000 and then divide by 1000 once the calculation is complete.
Then add some validation so anything that is not 0 and less than 0.001 is updated to 0.001?
In general I only allow players to split an inventory slot in half (e.g. 2 small scrolls), but if this resolves the floating-point issue I'm fine with it.
Observed Behavior
Items (X|Y)
will omitted if the display of theslotsUsed
takes up more horizontal space than is provided by the current window width.Root Cause
This comes up due to un-rounded floating point math. As the images provided in the observed behavior section illustrate, it is possible to have unexpectedly long values even when all item slot values are limited to single decimal place resolution.
Possible Solutions
slotsUsed
values to 2 or 3 decimal places of resolution.slotsUsed
always having the expected and readable value.slotsUsed
withMath.floor()
and append "+" to theslotsUsed
value.slotsUsed
elsewhere (perhaps in the token display bars?) would remain undesirably long.slotsUsed
withMath.ceil()
.9.30000000000000004
would be displayed as10
slots without causing HP to drop to 0, which could cause confusion.Math.floor()
solution in that it is display only.Use case
I prefer some granularity over the inventory items and frequently set items at 0.01 (100 per slot—useful for coins and gems), 0.1 (10 per slot—torches and rations if I'm being generous, otherwise things like chalk), and 0.5.
Possible enhancement: For the purpose of bundles, it would be easier to indicate count per slot than some fraction of a slot. Players and GMs coming from B/X are used to bundles of 6 torches, 7 rations, or 12 iron spikes, for example.