Advertisement
wolfd

Untitled

Jul 27th, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.06 KB | None | 0 0
  1. a_direction = "back"
  2. mon_direction = "top"
  3.  
  4. iteration = 1
  5. percent = {}
  6.  
  7. a = peripheral.wrap(a_direction)
  8. mon = peripheral.wrap(mon_direction)
  9. term.redirect(mon)
  10. term.setTextColor(colors.red)
  11. monitor_width, monitor_height = term.getSize()
  12.  
  13. function get_percent()
  14.     return (a.getFreeBytes() / a.getTotalBytes()) * 100
  15. end
  16.  
  17. function display(percent)
  18.     --width = (percent/100) * monitor_width
  19.     for i=1,monitor_width do
  20.         paintutils.drawLine(i, 0, i, monitor_height, colors.blue)
  21.     end
  22.     columns_to_display = math.min(monitor_width, table.getn(percent))
  23.     for i=1,columns_to_display do
  24.         term.write(tostring(percent[table.getn(percent) - columns_to_display + i]))
  25.         paintutils.drawLine(i, 0, i, monitor_height, colors.white)
  26.     end
  27.     term.setCursorPos(1,1)
  28.     term.write("change in fullness")
  29. end
  30.  
  31. function main()
  32.     percent[iteration] = get_percent()
  33.     iteration = iteration + 1
  34.     while true do
  35.         percent[iteration] = get_percent()
  36.         display(percent)
  37.         iteration = iteration + 1
  38.         sleep(1)
  39.     end
  40. end
  41.  
  42.  
  43.  
  44. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement