Advertisement
DumperJumper

Untitled

Jun 1st, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. local m = peripheral.wrap("top")
  2. m.clear()
  3. local sx, sy = m.getSize()
  4.  
  5. function m.writeError(text)
  6. m.setBackgroundColor(colors.red)
  7. m.setCursorPos(1, sy)
  8. m.write(text)
  9. m.setBackgroundColor(colors.black)
  10. end
  11.  
  12. function m.print(text)
  13. local x, y = m.getCursorPos()
  14. m.write(text)
  15. m.setCursorPos(1, y+1)
  16. end
  17.  
  18. function drawTaskBar()
  19. m.clearLine(sy)
  20. m.clearLine(1)
  21. m.setCursorPos(1, 1)
  22. m.write("Day: "..os.day())
  23. m.setCursorPos(sx-4, 1)
  24. m.write(textutils.formatTime(os.time(), true))
  25. m.setCursorPos(1, 2)
  26. for i=1, sx, 1 do
  27. m.write("-")
  28. end
  29.  
  30.  
  31. m.setCursorPos(1, 3)
  32. end
  33.  
  34. function DSUStorage()
  35. m.print("DSU Storage:")
  36.  
  37. rednet.open("bottom")
  38. local DSUSID = rednet.lookup("LHCP", "DSU_Controller")
  39. if DSUSID then
  40. rednet.send(DSUSID, "method:getDSUItems", "LHCP")
  41.  
  42. local sID, response = rednet.receive("LHCP", 5)
  43. if response then
  44. response = textutils.unserialize(response)
  45.  
  46. if tostring(response) and string.find(tostring(response), "error:") then
  47. m.writeError(response)
  48. break
  49. end
  50.  
  51. for k, v in ipairs(response) do
  52. local x, y = m.getCursorPos()
  53. m.write(v[1])
  54. m.setCursorPos(15, y)
  55. m.write(": ")
  56. m.write(tostring(v[2]))
  57. m.setCursorPos(1, y+1)
  58. end
  59. else
  60. m.writeError("Connection timed out on DSU_Controller")
  61. end
  62. else
  63. m.writeError("Couldn't connect to DSU_Controller")
  64. end
  65.  
  66. rednet.close("bottom")
  67. end
  68.  
  69. for id=1, 10, 1 do
  70. drawTaskBar()
  71. DSUStorage()
  72.  
  73. id = 1
  74. sleep(10)
  75. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement