Advertisement
cyber_Ahn

cytek status screen

Nov 1st, 2016
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.78 KB | None | 0 0
  1. --cyteck
  2. --status monitor for Newcytek-Server-World
  3.  
  4. local hw = {}
  5. local hwB = {}
  6. local hwD = {}
  7. local hwE = {}
  8. local reactor
  9. local storage
  10. --load API
  11. shell.run("delete caAPI")
  12. shell.run("pastebin get EDLdR1nF caAPI")
  13. os.loadAPI("caAPI")
  14.  
  15. -- format number for print
  16. function format(num)
  17. out = tostring(math.floor(num)).." J"
  18. if num > 1000000000000 then
  19. num = num / 1000000000000
  20. out = tostring(math.floor(num)).." TJ"
  21. end
  22. if num > 1000000000 then
  23. num = num / 1000000000
  24. out = tostring(math.floor(num)).." GJ"
  25. end
  26. if num > 1000000 then
  27. num = num / 1000000
  28. out = tostring(math.floor(num)).." MJ"
  29. end
  30. if num > 1000 then
  31. num = num / 1000
  32. out = tostring(math.floor(num)).." KJ"
  33. end
  34. return out
  35. end
  36.  
  37. --set monitor
  38. function set_monitor()
  39. local monitor_number = caAPI.get_hardware("monitor")
  40. local found = fs.exists("config/monitor.cfg")
  41. if found == true then
  42. file = fs.open("config/monitor.cfg","r")
  43. local fileData = {}
  44. local line = file.readLine()
  45. repeat
  46. table.insert(fileData,line)
  47. line = file.readLine()
  48. until line == nil
  49. file.close()
  50. monitor_number = fileData[1]
  51. end
  52. mon = peripheral.wrap(monitor_number)
  53. end
  54.  
  55. --search reactores and turbines
  56. function search()
  57. local periList = peripheral.getNames()
  58. for i = 1, #periList do
  59. if peripheral.getType(periList[i]) == "BigReactors-Reactor" then
  60. table.insert(hw,periList[i])
  61. end
  62. end
  63. local periList = peripheral.getNames()
  64. for i = 1, #periList do
  65. if peripheral.getType(periList[i]) == "BigReactors-Turbine" then
  66. table.insert(hwB,periList[i])
  67. end
  68. end
  69. end
  70.  
  71. --search mekanism maschine
  72. function searchB()
  73. local periList = peripheral.getNames()
  74. for i = 1, #periList do
  75. if peripheral.getType(periList[i]) == "mekanism_machine" then
  76. table.insert(hwD,periList[i])
  77. end
  78. end
  79. end
  80.  
  81. --search Energy Cells
  82. function searchC()
  83. local periList = peripheral.getNames()
  84. for i = 1, #periList do
  85. if peripheral.getType(periList[i]) == "powered_tile" then
  86. table.insert(hwE,periList[i])
  87. end
  88. end
  89. end
  90.  
  91. --draw screen
  92. function draw_screen()
  93. xi = true
  94. while xi == true do
  95. sleep(1)
  96. mon.setTextColor(1)
  97. mon.setBackgroundColor(colors.black)
  98. mon.clear()
  99. mon.setCursorPos(15,1)
  100. mon.setTextColor(colors.blue)
  101. num = #hw
  102. numB = #hwB
  103. mon.write("cytek Status Screen")
  104. line = 3
  105. for i = 1, #hw do
  106. mon.setCursorPos(2,line)
  107. mon.setTextColor(colors.red)
  108. mon.write("Reactor Port:"..hw[i])
  109. mon.setTextColor(colors.green)
  110. reactor = peripheral.wrap(hw[i])
  111. line = line + 1
  112. mon.setCursorPos(2,line)
  113. mon.write("Active:")
  114. mon.write(reactor.getActive())
  115. mon.write(" Rod:")
  116. mon.write(reactor.getControlRodLevel(0),"%")
  117. mon.write("%")
  118. line = line + 1
  119. mon.setCursorPos(2,line)
  120. mon.write("RF/T: ")
  121. mon.write(math.floor(reactor.getEnergyProducedLastTick()))
  122. mon.write(" RF Stored: ")
  123. mon.write(math.floor(reactor.getEnergyStored()))
  124. if math.floor(reactor.getEnergyStored()) > 9500000 then
  125. reactor.setAllControlRodLevels(100)
  126. end
  127. if math.floor(reactor.getEnergyStored()) < 5000000 then
  128. reactor.setAllControlRodLevels(0)
  129. end
  130. line = line + 1
  131. mon.setCursorPos(2,line)
  132. mon.write("Casing Heat: ")
  133. mon.write(math.floor(reactor.getCasingTemperature()))
  134. mon.write(" Fuel Heat: ")
  135. mon.write(math.floor(reactor.getFuelTemperature()))
  136. line = line + 2
  137. end
  138. for i = 1, #hwB do
  139. mon.setCursorPos(2,line)
  140. mon.setTextColor(colors.red)
  141. mon.write("Reactor Port:"..hwB[i])
  142. mon.setTextColor(colors.green)
  143. turbine = peripheral.wrap(hwB[i])
  144. line = line + 1
  145. mon.setCursorPos(2,line)
  146. mon.write("Active:")
  147. mon.write(turbine.getActive())
  148. line = line + 1
  149. mon.setCursorPos(2,line)
  150. mon.write("RF/T: ")
  151. mon.write(math.floor(turbine.getEnergyProducedLastTick()))
  152. mon.write(" RF Stored: ")
  153. mon.write(math.floor(turbine.getEnergyStored()))
  154. line = line + 2
  155. end
  156. for i = 1, #hwD do
  157. hwC = peripheral.wrap(hwD[i])
  158. nameC = hwC.getInventoryName()
  159. if nameC == "Induction Matrix" then
  160. storage = peripheral.wrap(hwD[i])
  161. end
  162. if nameC == "tile.Reactor.name.name" then
  163. reactorM = peripheral.wrap(hwD[i])
  164. end
  165. end
  166. storageN =  storage.getInventoryName()
  167. reactorN = "Reactor"
  168. mon.setCursorPos(2,line)
  169. mon.setTextColor(colors.red)
  170. mon.write(storageN)
  171. mon.setTextColor(colors.green)
  172. maxE = storage.getMaxEnergyStored()
  173. isE = storage.getEnergyStored()
  174. input = storage.getInput()
  175. output = storage.getOutput()
  176. precent = math.floor(100 * isE / maxE)
  177. maxF = format(maxE)
  178. isF = format(isE)
  179. inF = format(input)
  180. outF = format(output)
  181. line = line + 1
  182. mon.setCursorPos(2,line)
  183. mon.write("Max:"..maxF)
  184. line = line + 1
  185. mon.setCursorPos(2,line)
  186. mon.write("Is: "..isF.." "..tostring(precent).."%")
  187. line = line + 1
  188. mon.setCursorPos(2,line)
  189. mon.write("In: "..inF)
  190. line = line + 1
  191. mon.setCursorPos(2,line)
  192. mon.write("Out:"..outF)
  193. line = line - 4
  194. mon.setCursorPos(25,line)
  195. mon.setTextColor(colors.red)
  196. mon.write(reactorN)
  197. mon.setTextColor(colors.green)
  198. maxR = reactorM.getMaxEnergyStored()
  199. isR = reactorM.getEnergyStored()
  200. precentR = math.floor(100 * isR / maxR)
  201. maxFR = format(maxR)
  202. isFR = format(isR)
  203. line = line + 1
  204. mon.setCursorPos(25,line)
  205. mon.write("Max:"..maxFR)
  206. line = line + 1
  207. mon.setCursorPos(25,line)
  208. mon.write("Is: "..isFR.." "..tostring(precentR).."%")
  209. line = line + 4
  210. mon.setCursorPos(2,line)
  211. mon.setTextColor(colors.red)
  212. num = #hwE
  213. mon.write("Energy Cell Status Screen Found "..num.." Cells")
  214. mon.setTextColor(colors.green)
  215. line = line + 1
  216. mon.setCursorPos(2,line)
  217. start_x = 2
  218. start_y = line
  219. for i = 1, #hwE do
  220. cell = peripheral.wrap(hwE[i])
  221. max = cell.getMaxEnergyStored()
  222. stored = cell.getEnergyStored()
  223. percent = math.floor(100 * stored / max)
  224. mon.setCursorPos(start_x,start_y)
  225. mon.write(tostring(i)..": "..tostring(percent).."%")
  226. start_x = start_x + 10
  227. if i == 5 then
  228. start_x  = 2
  229. start_y = start_y + 2
  230. end
  231. if i == 10 then
  232. start_x  = 2
  233. start_y = start_y + 2
  234. end
  235. end
  236. end
  237. end
  238.  
  239. --prog start
  240. set_monitor()
  241. search()
  242. searchB()
  243. searchC()
  244. draw_screen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement