mirror of
https://github.com/minetest-mods/drawers.git
synced 2024-11-22 14:43:45 +01:00
New infotext format with percent
This commit is contained in:
parent
1862ddbef3
commit
ff11d6a518
@ -26,14 +26,12 @@ SOFTWARE.
|
|||||||
]]
|
]]
|
||||||
|
|
||||||
function drawers.gen_info_text(basename, count, factor, stack_max)
|
function drawers.gen_info_text(basename, count, factor, stack_max)
|
||||||
-- in the end it should look like:
|
local maxCount = stack_max * factor
|
||||||
-- Sand [4x99+43 / 24x99]
|
local percent = count / maxCount * 100
|
||||||
local countstr = tostring(math.floor(count / stack_max)) .. "x" ..
|
-- round the number (float -> int)
|
||||||
stack_max
|
percent = math.floor(percent + 0.5)
|
||||||
if count % stack_max ~= 0 then
|
|
||||||
countstr = countstr .. " + " .. count % stack_max
|
return tostring(count) .. " " .. basename .. " (" .. tostring(percent) .. "% full)"
|
||||||
end
|
|
||||||
return basename .. " [" .. countstr .. " / " .. factor .. "x" .. stack_max .. "]"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function drawers.get_inv_image(name)
|
function drawers.get_inv_image(name)
|
||||||
|
Loading…
Reference in New Issue
Block a user