Advertisement
Guest User

Untitled

a guest
Dec 18th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.74 KB | None | 0 0
  1. local component = require("component")
  2. local gpu = component.gpu
  3. local gbattery = component.get("34a07","induction_matrix")
  4. local batterie = component.proxy(gbattery)
  5.  
  6. function adjustUnit(value, unit)  -- prevent big numbers
  7.   if value >= 1000000000000 then
  8.     return tostring(round(value/1000000000000, 2)) .. "T" .. unit
  9.   elseif value >= 1000000000 then
  10.     return tostring(round(value/1000000000, 2)) .. "G" .. unit
  11.   elseif value >= 1000000 then
  12.     return tostring(round(value/1000000, 2)) .. "M" .. unit
  13.   elseif value >= 1000 then
  14.     return tostring(round(value/1000, 2)) .. "k" .. unit
  15.   else
  16.     return tostring(round(value)) .. unit
  17.   end
  18. end
  19.  
  20. while true do
  21. print(adjustUnit(batterie.getEnergy, "RF"))
  22. os.sleep(1)
  23. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement