Advertisement
bliind

Untitled

Jul 5th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. function num_fmt(num)
  2. num = tostring(num)
  3. len = #num
  4. commas = string.format("%d", (len / 3))
  5. commas = tonumber(commas)
  6. first = -3
  7. second = -1
  8. formatted = num:sub(first,second)
  9.  
  10. i = 0
  11. while i < commas do
  12. first = first - 3
  13. second = second - 3
  14. formatted = num:sub(first,second) .. "," .. formatted
  15. i = i + 1
  16. end
  17. return(formatted)
  18. end
  19.  
  20. cap = peripheral.wrap("tile_blockcapacitorbank_name_1")
  21. mon = peripheral.wrap("monitor_2")
  22.  
  23. capCount = 3
  24.  
  25. term.redirect(mon)
  26. term.clear()
  27.  
  28. sizex, sizey = term.getSize()
  29.  
  30.  
  31. while true do
  32. energy = cap.getEnergyStored()
  33. realEnergy = (energy * capCount)
  34. realEnergy = num_fmt(realEnergy)
  35. middle = ((sizex - #tostring(realEnergy)) / 2)
  36. term.setCursorPos(middle,1)
  37. print(realEnergy)
  38. sleep(1)
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement