Advertisement
cyber_Ahn

BigReactor Info Status automatic read and search in network

Aug 25th, 2016
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.87 KB | None | 0 0
  1. --BigReactor Info Status
  2. --automatic read and search in network
  3.  
  4. local hw = {}
  5. local hwB = {}
  6. --load API
  7. shell.run("delete caAPI")
  8. shell.run("pastebin get EDLdR1nF caAPI")
  9. os.loadAPI("caAPI")
  10.  
  11. --set monitor
  12. function set_monitor()
  13. local monitor_number = caAPI.get_hardware("monitor")
  14. local found = fs.exists("config/monitor.cfg")
  15. if found == true then
  16. file = fs.open("config/monitor.cfg","r")
  17. local fileData = {}
  18. local line = file.readLine()
  19. repeat
  20. table.insert(fileData,line)
  21. line = file.readLine()
  22. until line == nil
  23. file.close()
  24. monitor_number = fileData[1]
  25. end
  26. mon = peripheral.wrap(monitor_number)
  27. end
  28.  
  29. --search reactores and turbines
  30. function search()
  31. local periList = peripheral.getNames()
  32. for i = 1, #periList do
  33. if peripheral.getType(periList[i]) == "BigReactors-Reactor" then
  34. table.insert(hw,periList[i])
  35. end
  36. end
  37. local periList = peripheral.getNames()
  38. for i = 1, #periList do
  39. if peripheral.getType(periList[i]) == "BigReactors-Turbine" then
  40. table.insert(hwB,periList[i])
  41. end
  42. end
  43. end
  44.  
  45. --draw screen
  46. function draw_screen()
  47. xi = true
  48. while xi == true do
  49. sleep(1)
  50. mon.setTextColor(1)
  51. mon.setBackgroundColor(colors.black)
  52. mon.clear()
  53. mon.setCursorPos(2,1)
  54. mon.setTextColor(colors.blue)
  55. num = #hw
  56. numB = #hwB
  57. mon.write("Reactor Status Screen")
  58. mon.setCursorPos(2,2)
  59. mon.write("Found "..num.." Reactors "..numB.." Turbines")
  60. line = 3
  61. for i = 1, #hw do
  62. mon.setCursorPos(2,line)
  63. mon.setTextColor(colors.red)
  64. mon.write("Reactor Port:"..hw[i])
  65. mon.setTextColor(colors.green)
  66. reactor = peripheral.wrap(hw[i])
  67. line = line + 1
  68. mon.setCursorPos(2,line)
  69. mon.write("Active:")
  70. mon.write(reactor.getActive())
  71. mon.write(" Rod:")
  72. mon.write(reactor.getControlRodLevel(0),"%")
  73. mon.write("%")
  74. line = line + 1
  75. mon.setCursorPos(2,line)
  76. mon.write("RF/T: ")
  77. mon.write(math.floor(reactor.getEnergyProducedLastTick()))
  78. mon.write(" RF Stored: ")
  79. mon.write(math.floor(reactor.getEnergyStored()))
  80. if math.floor(reactor.getEnergyStored()) > 9500000 then
  81. reactor.setAllControlRodLevels(100)
  82. end
  83. if math.floor(reactor.getEnergyStored()) < 5000000 then
  84. reactor.setAllControlRodLevels(0)
  85. end
  86. line = line + 1
  87. mon.setCursorPos(2,line)
  88. mon.write("Casing Heat: ")
  89. mon.write(math.floor(reactor.getCasingTemperature()))
  90. mon.write(" Fuel Heat: ")
  91. mon.write(math.floor(reactor.getFuelTemperature()))
  92. line = line + 2
  93. end
  94. for i = 1, #hwB do
  95. mon.setCursorPos(2,line)
  96. mon.setTextColor(colors.red)
  97. mon.write("Reactor Port:"..hwB[i])
  98. mon.setTextColor(colors.green)
  99. turbine = peripheral.wrap(hwB[i])
  100. line = line + 1
  101. mon.setCursorPos(2,line)
  102. mon.write("Active:")
  103. mon.write(turbine.getActive())
  104. line = line + 1
  105. mon.setCursorPos(2,line)
  106. mon.write("RF/T: ")
  107. mon.write(math.floor(turbine.getEnergyProducedLastTick()))
  108. mon.write(" RF Stored: ")
  109. mon.write(math.floor(turbine.getEnergyStored()))
  110. line = line + 2
  111. end
  112. end
  113. end
  114.  
  115. --prog start
  116. set_monitor()
  117. search()
  118. draw_screen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement