View difference between Paste ID: 32hW5670 and Pk8B1NUE
SHOW: | | - or go back to the newest paste.
1-
--[[
1+
--[[
2-
This is free and unencumbered software released into the public domain.
2+
This is free and unencumbered software released into the public domain.
3-
3+
4-
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
Anyone is free to copy, modify, publish, use, compile, sell, or
5-
distribute this software, either in source code form or as a compiled
5+
distribute this software, either in source code form or as a compiled
6-
binary, for any purpose, commercial or non-commercial, and by any
6+
binary, for any purpose, commercial or non-commercial, and by any
7-
means.
7+
means.
8-
8+
9-
Read the full license on ( http://unlicense.org )
9+
Read the full license on ( http://unlicense.org )
10-
Original code made by Rph
10+
Original code made by Rph
11-
]]--
11+
]]--
12-
12+
13-
local api = {}
13+
local api = {}
14-
function api.convert( nValue )
14+
function api.convert( nValue )
15-
    local unit = " J"
15+
    local unit = " J"
16-
    if nValue > 999 and nValue < 1000000 then
16+
    if nValue > 999 and nValue < 1000000 then
17-
        unit = " KJ"
17+
        unit = " KJ"
18-
        return math.floor(nValue / 1000) .. unit
18+
        return math.floor(nValue / 1000) .. unit
19-
    elseif nValue > 999999 and nValue < 1000000000 then
19+
    elseif nValue > 999999 and nValue < 1000000000 then
20-
        unit = " MJ"
20+
        unit = " MJ"
21-
        return math.floor(nValue / 1000000) .. unit
21+
        return math.floor(nValue / 1000000) .. unit
22-
    elseif nValue > 999999999 then
22+
    elseif nValue > 999999999 then
23-
        unit = " GJ"
23+
        unit = " GJ"
24-
        return math.floor(nValue / 1000000000) .. unit
24+
        return math.floor(nValue / 1000000000) .. unit
25-
    else
25+
    else
26-
        return nValue .. unit
26+
        return nValue .. unit
27-
    end
27+
    end
28-
    return "Wot"
28+
    return "Wot"
29-
end
29+
end
30
return api