Advertisement
battlemanmk2

EnergyNumberFormatter

Jul 5th, 2022 (edited)
883
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.33 KB | None
  1. --Get a number in a human-readable format
  2. --This is used to display numbers on the screen
  3.  
  4. --@param inputNumber The Number to format
  5. --@return The formatted number
  6.  
  7. ENF = {}
  8.  
  9. function ENF.formatNumber(inputNumber)
  10.     local number = (inputNumber / 2.5)
  11.     local round = 0
  12.     local texts = ""
  13.  
  14.     if number >= 1000000000000000000 then
  15.         round = (number / 1000000000000000000)
  16.     texts = string.sub(round, 0, 5) .. " EFE"
  17.   else
  18.     if number >= 1000000000000000 then
  19.       round = (number / 1000000000000000)
  20.       texts = string.sub(round, 0, 5) .. " PFE"
  21.     else
  22.       if number >= 1000000000000 then
  23.         round = (number / 1000000000000)
  24.         texts = string.sub(round, 0, 5) .. " TFE"
  25.       else
  26.         if number >= 1000000000 then
  27.           round = (number / 1000000000)
  28.           texts = string.sub(round, 0, 5) .. " GFE"
  29.         else
  30.           if number >= 1000000 then
  31.             round = (number / 1000000)
  32.             texts = string.sub(round, 0, 5) .. " MFE"
  33.           else
  34.             if number >= 1000 then
  35.               round = (number / 1000)
  36.               texts = string.sub(round, 0, 5) .. " kFE"
  37.               else
  38.                 texts = string.sub(number, 0, 5) .. "  FE"
  39.                 end
  40.               end
  41.             end
  42.           end
  43.         end
  44.       end
  45.     return texts
  46.   end
  47. return ENF
Advertisement
RAW Paste Data Copied
Advertisement