Advertisement
fishermedders

mesys control cc

Jul 20th, 2015
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. me = peripheral.wrap("me_drive_0")
  2. m = peripheral.wrap("top")
  3. msize = {m.getSize()}
  4. function draw_line(x, y, length, color)
  5. mon.setBackgroundColor(color)
  6. mon.setCursorPos(x,y)
  7. mon.write(string.rep(" ", length))
  8. end
  9. function progress_bar(x, y, length, minVal, maxVal, bar_color, bg_color)
  10. draw_line(x, y, length, bg_color) --backgoround bar
  11. local barSize = math.floor((minVal/maxVal) * length)
  12. draw_line(x, y, barSize, bar_color) --progress so far
  13. end
  14. function drawScreen()
  15. m.clear()
  16. m.setCursorPos(1,1)
  17. m.setBackgroundColor(colors.blue)
  18. for i = 1,msize[1] do
  19. m.write(" ")
  20. end
  21. m.setCursorPos(1,msize[2])
  22. --for i = 1,msize[1] do
  23. m.write(" SpaceJunkies MESys Control! ")
  24. --end
  25. m.setBackgroundColor(colors.black)
  26. m.setTextColor(colors.yellow)
  27. m.setCursorPos(2,3)
  28. m.write("Status: ")
  29. if me.getUnusedBytes() == 0 then
  30. m.setTextColor(colors.red)
  31. m.write("Offline")
  32. else
  33. m.setTextColor(colors.lime)
  34. m.write("Online")
  35. m.setCursorPos(2,5)
  36. m.setTextColor(colors.yellow)
  37. m.write("Storage Used: ")
  38. gub = tonumber(me.getTotalBytes())-tonumber(me.getFreeBytes())
  39. pc = (gub/tonumber(me.getTotalBytes()))*100
  40. if string.find(pc,".") then
  41. find = string.find(pc,".")
  42. pc = string.sub(pc,1,find+1)
  43. end
  44. m.write(pc.."%")
  45. end
  46. end
  47.  
  48. drawScreen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement