ksbd

Redstone Energy Cell Auto-Refuel (Monitor)

Jan 25th, 2013
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.44 KB | None | 0 0
  1. local C1, C2, C3, C4, C5, C6, C7, C8 = 96, 97, 99, 100, 101, 102, 103, 104
  2. local C1v, C2v, C3v, C4v, C5v, C6v, C7v, C8v = "No Data", "No Data", "No Data", "No Data", "No Data", "No Data", "No Data", "No Data"
  3. local compID, value, distance = "No Data", "No Data", "No Data"
  4. local m = peripheral.wrap("back")
  5.  
  6. function white()
  7.     term.setTextColor(colors.white)
  8. end
  9.  
  10. function clear()
  11.     term.clear()
  12.     term.setCursorPos(1,1)
  13. end
  14.  
  15. function netClose()
  16.     rednet.close("right")
  17. end
  18.  
  19. function netOpen()
  20.     netClose()
  21.     rednet.open("right")
  22. end
  23.  
  24. function getData()
  25.     compID, value, distance = rednet.receive()
  26. end
  27.  
  28. function assignData()
  29.     netOpen()
  30.     getData()
  31.     if compID == C1 then
  32.         C1v = value
  33.     elseif compID == C2 then
  34.         C2v = value
  35.     elseif compID == C3 then
  36.         C3v = value
  37.     elseif compID == C4 then
  38.         C4v = value
  39.     elseif compID == C5 then
  40.         C5v = value
  41.     elseif compID == C6 then
  42.         C6v = value
  43.     elseif compID == C7 then
  44.         C7v = value
  45.     elseif compID == C8 then
  46.         C8v = value
  47.     end
  48. end
  49.  
  50. while true do
  51.     assignData()
  52.     term.redirect(m)
  53.     clear()
  54.     term.setTextColor(colors.lightBlue)
  55.     print("Charging Station Status:") print("________________________")
  56.     term.setTextColor(colors.white)
  57.     print("")
  58.     term.write("Station 1: ")  
  59.         if C1v == "Charging" then term.setTextColor(colors.red)
  60.         elseif C1v == "Full" then term.setTextColor(colors.lime)
  61.         elseif C1v == "Absent" then term.setTextColor(colors.orange)
  62.         else term.setTextColor(colors.lightGray) end
  63.     print(C1v)
  64.     white()
  65.     term.write("Station 2: ")  
  66.         if C2v == "Charging" then term.setTextColor(colors.red)
  67.         elseif C2v == "Full" then term.setTextColor(colors.lime)
  68.         elseif C2v == "Absent" then term.setTextColor(colors.orange)
  69.         else term.setTextColor(colors.lightGray) end
  70.     print(C2v)
  71.     white()
  72.     term.write("Station 3: ")  
  73.         if C3v == "Charging" then term.setTextColor(colors.red)
  74.         elseif C3v == "Full" then term.setTextColor(colors.lime)
  75.         elseif C3v == "Absent" then term.setTextColor(colors.orange)
  76.         else term.setTextColor(colors.lightGray) end
  77.     print(C3v)
  78.     white()
  79.     term.write("Station 4: ")  
  80.         if C4v == "Charging" then term.setTextColor(colors.red)
  81.         elseif C4v == "Full" then term.setTextColor(colors.lime)
  82.         elseif C4v == "Absent" then term.setTextColor(colors.orange)
  83.         else term.setTextColor(colors.lightGray) end
  84.     print(C4v)
  85.     white()
  86.     term.write("Station 5: ")  
  87.         if C5v == "Charging" then term.setTextColor(colors.red)
  88.         elseif C5v == "Full" then term.setTextColor(colors.lime)
  89.         elseif C5v == "Absent" then term.setTextColor(colors.orange)
  90.         else term.setTextColor(colors.lightGray) end
  91.     print(C5v)
  92.     white()
  93.     term.write("Station 6: ")  
  94.         if C6v == "Charging" then term.setTextColor(colors.red)
  95.         elseif C6v == "Full" then term.setTextColor(colors.lime)
  96.         elseif C6v == "Absent" then term.setTextColor(colors.orange)
  97.         else term.setTextColor(colors.lightGray) end
  98.     print(C6v)
  99.     white()
  100.     term.write("Station 7: ")  
  101.         if C7v == "Charging" then term.setTextColor(colors.red)
  102.         elseif C7v == "Full" then term.setTextColor(colors.lime)
  103.         elseif C7v == "Absent" then term.setTextColor(colors.orange)
  104.         else term.setTextColor(colors.lightGray) end
  105.     print(C7v)
  106.     white()
  107.     term.write("Station 8: ")  
  108.         if C8v == "Charging" then term.setTextColor(colors.red)
  109.         elseif C8v == "Full" then term.setTextColor(colors.lime)
  110.         elseif C8v == "Absent" then term.setTextColor(colors.orange)
  111.         else term.setTextColor(colors.lightGray) end
  112.     print(C8v)
  113.     white()
  114.     term.restore()
  115. end
Advertisement
Add Comment
Please, Sign In to add comment