summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLNJ <git@lnj.li>2017-04-01 20:24:32 +0200
committerLNJ <git@lnj.li>2017-04-01 20:24:32 +0200
commitff11d6a518694eee51718666c1d6fa509e06da36 (patch)
treeb10eb3fb247a1bd49c68916d4d5935702b8e53d6
parent1862ddbef367dd1fd43cc7feb051e0b043e979ba (diff)
New infotext format with percent
-rwxr-xr-xlua/helpers.lua14
1 files changed, 6 insertions, 8 deletions
diff --git a/lua/helpers.lua b/lua/helpers.lua
index 11263f4..173a472 100755
--- a/lua/helpers.lua
+++ b/lua/helpers.lua
@@ -26,14 +26,12 @@ SOFTWARE.
]]
function drawers.gen_info_text(basename, count, factor, stack_max)
- -- in the end it should look like:
- -- Sand [4x99+43 / 24x99]
- local countstr = tostring(math.floor(count / stack_max)) .. "x" ..
- stack_max
- if count % stack_max ~= 0 then
- countstr = countstr .. " + " .. count % stack_max
- end
- return basename .. " [" .. countstr .. " / " .. factor .. "x" .. stack_max .. "]"
+ local maxCount = stack_max * factor
+ local percent = count / maxCount * 100
+ -- round the number (float -> int)
+ percent = math.floor(percent + 0.5)
+
+ return tostring(count) .. " " .. basename .. " (" .. tostring(percent) .. "% full)"
end
function drawers.get_inv_image(name)