New infotext format with percent

This commit is contained in:
LNJ 2017-04-01 20:24:32 +02:00
parent 1862ddbef3
commit ff11d6a518
No known key found for this signature in database
GPG Key ID: 69268DBD835B6B0B

@ -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)