Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display units on current amount #6

Open
mkmarq opened this issue Nov 30, 2020 · 2 comments
Open

Display units on current amount #6

mkmarq opened this issue Nov 30, 2020 · 2 comments

Comments

@mkmarq
Copy link

mkmarq commented Nov 30, 2020

Need to show units on the current amount for clarity.

For example, right now if I see 54.0/192.0kL, it is impossible to tell from the numbers alone whether it means 54L or 54kL.

@carmopereira
Copy link
Owner

when i did it it seem right... but now at distance i don't like it either.

@mkmarq
Copy link
Author

mkmarq commented Dec 2, 2020

Direct replacement for litreParse that I think addresses the problem:

function litreParse(litre, total)
    return getValueWithUnits(litre) .. "/" .. getValueWithUnits(total)
end

function getValueWithUnits(value)
    local size = ""
    if value < 1000 then
        size = "L"
    elseif value < 1000000 then
        value = value / 1000
        size = "kL"
    else
        value = value / 1000000
        size = "kt"
    end
    
    return string.format("%.1f",value)..size
end

Hope it's useful :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants