skare

Untitled

Dec 2nd, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.27 KB | None | 0 0
  1.  
  2.  
  3. local version="8.0"
  4.  
  5. local component = require("component")
  6. local computer = require("computer")
  7. local event = require("event")
  8. local term = require("term")
  9. local sides = require("sides")
  10.  
  11. local gpu = component.gpu
  12. local beep = component.computer.beep
  13. local reactor=component.reactor_chamber
  14.  
  15. local rodSlot = component.inventory_controller.getStackInSlot
  16.  
  17. --reactor
  18. Heat=reactor.getMaxHeat
  19. getHeat=reactor.getHeat
  20. EUOutput=reactor.getReactorEUOutput
  21. --reactor
  22.  
  23. --tables
  24. local items={}
  25. local currentRods={}
  26. local rodTypes={"gt.reactorUraniumQuad.name", "gt.reactorMOXQuad.name", "gt.Quad_Thoriumcell.name"}
  27. local rodEmpty={"Quad Fuel Rod (Depleted Uranium)", "Quad Fuel Rod (Depleted MOX)", "gt.Quad_ThoriumcellDep.name"}
  28. --tables
  29.  
  30. --rods
  31. local rod1 = rodSlot(1, 21)
  32. local rod2 = rodSlot(1, 25)
  33. local rod3 = rodSlot(1, 30)
  34. local rod4 = rodSlot(1, 34)
  35. --rods
  36.  
  37. --rod functions
  38. local function draw1()
  39. if currentRods[1] == rodTypes[1] then
  40. return "U"
  41. elseif currentRods[1] == rodEmpty[1] then
  42. return "0"
  43. elseif currentRods[1] == rodTypes[2] then
  44. return "M"
  45. elseif currentRods[1] == rodEmpty[2] then
  46. return "0"
  47. elseif currentRods[1] == rodTypes[3] then
  48. return "T"
  49. elseif currentRods[1] == rodEmpty[3] then
  50. return "0"
  51. elseif currentRods[1] == "empty" then
  52. return "E"
  53. end
  54. end
  55.  
  56. local function draw2()
  57. if currentRods[2] == rodTypes[1] then
  58. return "U"
  59. elseif currentRods[2] == rodEmpty[1] then
  60. return "0"
  61. elseif currentRods[2] == rodTypes[2] then
  62. return "M"
  63. elseif currentRods[2] == rodEmpty[2] then
  64. return "0"
  65. elseif currentRods[2] == rodTypes[3] then
  66. return "T"
  67. elseif currentRods[2] == rodEmpty[3] then
  68. return "0"
  69. elseif currentRods[2] == "empty" then
  70. return "E"
  71. end
  72. end
  73.  
  74. local function draw3()
  75. if currentRods[3] == rodTypes[1] then
  76. return "U"
  77. elseif currentRods[3] == rodEmpty[1] then
  78. return "0"
  79. elseif currentRods[3] == rodTypes[2] then
  80. return "M"
  81. elseif currentRods[3] == rodEmpty[2] then
  82. return "0"
  83. elseif currentRods[3] == rodTypes[3] then
  84. return "T"
  85. elseif currentRods[3] == rodEmpty[3] then
  86. return "0"
  87. elseif currentRods[3] == "empty" then
  88. return "E"
  89. end
  90. end
  91.  
  92. local function draw4()
  93. if currentRods[4] == rodTypes[1] then
  94. return "U"
  95. elseif currentRods[4] == rodEmpty[1] then
  96. return "0"
  97. elseif currentRods[4] == rodTypes[2] then
  98. return "M"
  99. elseif currentRods[4] == rodEmpty[2] then
  100. return "0"
  101. elseif currentRods[4] == rodTypes[3] then
  102. return "T"
  103. elseif currentRods[4] == rodEmpty[3] then
  104. return "0"
  105. elseif currentRods[4] == "empty" then
  106. return "E"
  107. end
  108. end
  109. --rod functions
  110.  
  111. --colors
  112. local black = 0x000000
  113. local red = 0xFF0000
  114. local yellow = 0xFFFF00
  115. local white = 0xffffff
  116. --colors
  117.  
  118. local start_time = computer.uptime()
  119.  
  120. local modem = component.modem
  121.  
  122. local w,h = gpu.getResolution()
  123.  
  124. --maxResolution() 160x50 if 3x2blocks w,h
  125.  
  126. -- place for config
  127. -------------------
  128. -- end of config
  129.  
  130.  
  131. --start_time
  132.  
  133. --timer
  134. local tickCnt = 0
  135. local running = true
  136. local hours = 0
  137. local mins = 0
  138. --timer
  139.  
  140. local function centerF(row, msg, ...)
  141. local mLen = string.len(msg)
  142. w, h = gpu.getResolution()
  143. term.setCursor((w - mLen)/2,row)
  144. print(msg:format(...))
  145. end
  146.  
  147. --more functions
  148. local function status()
  149. if EUOutput() == 0 then
  150. return "offline"
  151. else
  152. return "online "
  153. end
  154. end
  155.  
  156. local function maxheat()
  157. return reactor.getMaxHeat()
  158. end
  159.  
  160. local function getheat()
  161. if getHeat() == 0 then
  162. return "0 "
  163. else
  164. return reactor.getHeat()
  165. end
  166. end
  167.  
  168. local function getEU()
  169. if EUOutput() == 0 then
  170. return "0 "
  171. else
  172. return reactor.getReactorEUOutput()
  173. end
  174. end
  175. --more functions
  176.  
  177. gpu.setForeground(0xffffff)
  178.  
  179.  
  180. -----
  181. term.clear()
  182. term.setCursor(1,1)
  183.  
  184. centerF(5, "-----------------------------------------")
  185. centerF(6, "- IC2 Reactor Controller V8 -")
  186. centerF(7, "-----------------------------------------")
  187. centerF(8, string.format("- Reactor is: %s -",status()))
  188. centerF(9, string.format("- Reactor maxheat: %s -",maxheat()))
  189. centerF(10, string.format("- Reactor heat: %s -", getheat()))
  190. centerF(11, string.format("- Reactor EU Output: %s -", getEU()))
  191. centerF(12, "-----------------------------------------")
  192. centerF(13, "- -")
  193. centerF(14, "-----------------------------------------")
  194.  
  195. while true do
  196.  
  197. centerF(15, "-----------------------------")
  198. centerF(16, "- Reactor Fuel Rods -")
  199. centerF(17, "-----------------------------")
  200. centerF(18, " ")
  201. centerF(19, " --------- ")
  202. centerF(20, " ")
  203. centerF(21, " ")
  204. centerF(22, " --------- ")
  205. centerF(23, " ")
  206. centerF(24, "-----------------------------")
  207.  
  208. tickCnt = tickCnt + 1
  209. if tickCnt == 60 then
  210. mins = mins + 1
  211. tickCnt = 0
  212. end
  213.  
  214. if mins == 60 then
  215. hours = hours + 1
  216. mins = 0
  217. end
  218.  
  219. rod1 = rodSlot(1, 21)
  220. if rod1 ~= nil then
  221. currentRods[1]=rod1.label
  222. else
  223. currentRods[1]="empty"
  224. end
  225.  
  226. rod2 = rodSlot(1, 25)
  227. if rod2 ~= nil then
  228. currentRods[2]=rod2.label
  229. else
  230. currentRods[2]="empty"
  231. end
  232.  
  233. rod3 = rodSlot(1, 30)
  234. if rod3 ~= nil then
  235. currentRods[3]=rod3.label
  236. else
  237. currentRods[3]="empty"
  238. end
  239.  
  240. rod4 = rodSlot(1, 34)
  241. if rod4 ~= nil then
  242. currentRods[4]=rod4.label
  243. else
  244. currentRods[4]="empty"
  245. end
  246.  
  247. centerF(20, string.format("--%s---%s--",draw1(),draw2()))
  248. centerF(21, string.format("--%s---%s--",draw3(),draw4()))
  249.  
  250. centerF(8, string.format("- Reactor is: %s -",status()))
  251. centerF(9, string.format("- Reactor maxheat: %s -",maxheat()))
  252. centerF(10, string.format("- Reactor heat: %s -", getheat()))
  253. centerF(11, string.format("- Reactor EU Output: %s -", getEU()))
  254. centerF(30, "Data updates every second: %2d", tickCnt)
  255. centerF(31, "Current up time: %2d hours %2d min", hours, mins)
  256.  
  257. --beep()
  258. os.sleep(1)
  259.  
  260. end
Add Comment
Please, Sign In to add comment