Advertisement
NekoTiki

Untitled

Dec 4th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local modem = peripheral.wrap("top")
  2. local mon = peripheral.wrap("bottom")
  3.  
  4. modem.open(2)
  5.  
  6. function roundTo(number, scale)
  7.     local num = number
  8.     for i=0,scale do
  9.         num = num * 10
  10.     end
  11.  
  12.     num = math.floor(num)
  13.  
  14.     for i=0,scale do
  15.         num = num / 10
  16.     end
  17.  
  18.     return num
  19. end
  20.  
  21. function numberToText(number)
  22.     local num = tonumber(number)
  23.     if num >= 1000000000000 then return (roundTo((num/1000000000000), 2) .. " T") end
  24.     if num >= 1000000000 then return (roundTo((num/1000000000), 2) .. " G") end
  25.     if num >= 1000000 then return (roundTo((num/1000000), 2) .. " M") end
  26.     if num >= 1000 then return (roundTo((num/1000), 2) .. " k") end
  27. end
  28.  
  29. while true do
  30.     modem.transmit(1,2,"getEnergy")
  31.     local event, mS, sC, rC,
  32.           data, sD = os.pullEvent("modem_message")
  33.    
  34.     print(data["en"] .. " - " .. data["enPT"])
  35.     mon.clear()
  36.     mon.setTextScale(3)
  37.     mon.setCursorPos(1,1)
  38.     mon.write(numberToText(data["en"]))
  39.    
  40.     sleep(1)
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement