Advertisement
Guest User

startup

a guest
Jun 27th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.98 KB | None | 0 0
  1. mon = peripheral.wrap("left")
  2. modem = peripheral.wrap("back")
  3. r = peripheral.wrap("BigReactors-Reactor_6")
  4.  
  5. override = false
  6. manOver = colors.red
  7. overrideStatus = "Disabled"
  8. MO = 1
  9.  
  10. function autoReactor()
  11.  
  12. energyCap = r.getEnergyCapacity()
  13. energyStored = r.getEnergyStored()
  14.  
  15. energyPerc = 100*(energyStored/energyCap)
  16.  
  17. if energyPerc > 70 then
  18. setOn = 0
  19. else
  20. setOn = 1
  21. end
  22.  
  23. if setOn == 1 then
  24. r.setActive(true)
  25. else
  26. r.setActive(false)
  27. end
  28. end
  29.  
  30.  
  31. function touchLoc()
  32.     _,_,xPos,yPos = os.pullEvent("monitor_touch")
  33. end
  34.  
  35. function withinBox(x,y,xEnd,yEnd)
  36.     if x <= xPos and xEnd >= xPos and y <= yPos and yEnd >= yPos then
  37.     return true
  38.     else
  39.     return false
  40.     end
  41. end
  42.  
  43. term.redirect(mon)
  44. mon.setTextScale(0.5)
  45.  
  46. term.setBackgroundColor(colors.black)
  47. term.clear()
  48.  
  49. function main_loop()
  50. while true do
  51.  
  52. energy = r.getEnergyStored()
  53. gActive = r.getActive()
  54. gEnergyCap = r.getEnergyCapacity()
  55. gEnergyProd = r.getEnergyProducedLastTick()
  56. gFuelAmt = r.getFuelAmount()
  57. gFuelAmtM = r.getFuelAmountMax()
  58. gFuelCons = r.getFuelConsumedLastTick()
  59. gFuelReact = r.getFuelReactivity()
  60. gCasingTemp = r.getCasingTemperature()
  61. gFuelTemp = r.getFuelTemperature()
  62.  
  63. energyPerc = math.ceil(100*(energy/gEnergyCap))
  64.  
  65. fuelPerc = math.ceil(100*(gFuelAmt/gFuelAmtM))
  66.  
  67. fuelTime = math.floor(1000/(20*gFuelCons))
  68.  
  69. term.setBackgroundColor(colors.black)
  70. term.clear()
  71.  
  72. --Info Box
  73. infoBox = window.create(term.current(),4,2,6,1)
  74. paintutils.drawBox(2,2,47,26,colors.gray)
  75. infoBox.setBackgroundColor(colors.black)
  76. infoBox.setTextColor(colors.blue)
  77. infoBox.setCursorPos(1,1)
  78. infoBox.write(" Info ")
  79. energyLevel = window.create(term.current(),6,4,19,1)
  80. energyLevel.setTextColor(colors.blue)
  81. energyLevel.write("Energy Level: ")
  82. energyLevel.setTextColor(colors.yellow)
  83. energyLevel.write(energyPerc)
  84. energyLevel.setTextColor(colors.orange)
  85. energyLevel.write("%")
  86. paintutils.drawBox(4,5,45,13,colors.lightGray)
  87. paintutils.drawFilledBox(5,6,44,12,colors.gray)
  88. energyBar = (44*energyPerc)/100
  89. if energyPerc > 90 then
  90. energyBarColor = colors.lime
  91. elseif energyPerc > 75 then
  92. energyBarColor = colors.green
  93. elseif energyPerc > 50 then
  94. energyBarColor = colors.yellow
  95. elseif energyPerc > 25 then
  96. energyBarColor = colors.orange
  97. else
  98. energyBarColor = colors.red
  99. end
  100. paintutils.drawFilledBox(5,6,energyBar,12,energyBarColor)
  101. fuelLevel = window.create(term.current(),6,15,20,1)
  102. fuelLevel.setTextColor(colors.blue)
  103. fuelLevel.write("Fuel Level: ")
  104. fuelLevel.setTextColor(colors.yellow)
  105. fuelLevel.write(fuelPerc)
  106. fuelLevel.setTextColor(colors.orange)
  107. fuelLevel.write("%")
  108. paintutils.drawBox(4,16,45,24,colors.lightGray)
  109. paintutils.drawFilledBox(5,17,44,23,colors.gray)
  110. fuelBar = (44*fuelPerc)/100
  111. if fuelPerc > 90 then
  112. fuelBarColor = colors.lime
  113. elseif fuelPerc > 75 then
  114. fuelBarColor = colors.green
  115. elseif fuelPerc > 50 then
  116. fuelBarColor = colors.yellow
  117. elseif fuelPerc > 25 then
  118. fuelBarColor = colors.orange
  119. else
  120. fuelBarColor = colors.red
  121. end
  122. paintutils.drawFilledBox(5,17,fuelBar,23,fuelBarColor)
  123.  
  124. --Manual Override Box
  125. manualBox = window.create(term.current(),51,2,10,1)
  126. paintutils.drawBox(49,2,78,12,colors.gray)
  127. manualBox.setBackgroundColor(colors.black)
  128. manualBox.setTextColor(colors.blue)
  129. manualBox.setCursorPos(1,1)
  130. manualBox.write(" Override ")
  131.  
  132. --Override Buttons
  133. manualInside = window.create(term.current(),51,5,16,1)
  134. manualInside.write("  Override:  ")
  135. paintutils.drawFilledBox(66,4,75,6,manOver)
  136. manualButtonText = window.create(term.current(),67,5,8,1)
  137. manualButtonText.setBackgroundColor(manOver)
  138. manualButtonText.write(overrideStatus)
  139. paintutils.drawFilledBox(52,8,61,10,colors.green)
  140. manualOn = window.create(term.current(),56,9,2,1)
  141. manualOn.setBackgroundColor(colors.green)
  142. manualOn.write("On")
  143. paintutils.drawFilledBox(66,8,75,10,colors.red)
  144. manualOff = window.create(term.current(),69,9,3,1)
  145. manualOff.setBackgroundColor(colors.red)
  146. manualOff.write("Off")
  147.  
  148. --Status Box
  149. statusBox = window.create(term.current(),51,14,8,1)
  150. paintutils.drawBox(49,14,78,37,colors.gray)
  151. statusBox.setBackgroundColor(colors.black)
  152. statusBox.setTextColor(colors.blue)
  153. statusBox.setCursorPos(1,1)
  154. statusBox.write(" Status ")
  155. statusInside = window.create(term.current(),51,16,26,20)
  156. statusInside.setCursorPos(2,2)
  157.  
  158. --Status
  159. if gActive == true then
  160.     status = "On"
  161.     statusColor = colors.green
  162. else
  163.     status = "Off"
  164.     statusColor = colors.red
  165. end
  166. statusInside.write("     Status:  ")
  167. statusInside.setTextColor(statusColor)
  168. statusInside.write(status)
  169. statusInside.setTextColor(colors.white)
  170. statusInside.setCursorPos(2,5)
  171. statusInside.write("  Producing:  ")
  172. statusInside.setTextColor(statusColor)
  173. statusInside.write(math.floor(gEnergyProd))
  174. statusInside.setTextColor(colors.white)
  175. statusInside.write(" RF/t")
  176. statusInside.setCursorPos(2,8)
  177. statusInside.write(" Reactivity:  ")
  178. statusInside.setTextColor(colors.blue)
  179. statusInside.write(math.floor(gFuelReact))
  180. statusInside.setTextColor(colors.white)
  181. statusInside.write("%")
  182. statusInside.setCursorPos(2,11)
  183. if gCasingTemp > 2000 then
  184. casingTempColor = colors.red
  185. elseif gCasingTemp > 1500 then
  186. casingTempColor = colors.orange
  187. elseif gCasingTemp > 1000 then
  188. casingTempColor = colors.yellow
  189. elseif gCasingTemp > 500 then
  190. casingTempColor = colors.white
  191. elseif gCasingTemp > 250 then
  192. casingTempColor = colors.blue
  193. else
  194. casingTempColor = colors.lightBlue
  195. end
  196. statusInside.write("Casing Temp:  ")
  197. statusInside.setTextColor(casingTempColor)
  198. statusInside.write(math.floor(gCasingTemp))
  199. statusInside.setTextColor(colors.white)
  200. statusInside.write("`C")
  201. statusInside.setCursorPos(2,14)
  202. statusInside.write("  Fuel Temp:  ")
  203. statusInside.setTextColor(casingTempColor)
  204. statusInside.write(math.floor(gFuelTemp))
  205. statusInside.setTextColor(colors.white)
  206. statusInside.write("`C")
  207. statusInside.setCursorPos(2,18)
  208. if gActive == true then
  209. fuelTime = fuelTime
  210. else
  211. fuelTime = "--"
  212. end
  213. statusInside.write("Each Ingot Lasts ")
  214. statusInside.setTextColor(colors.blue)
  215. statusInside.write(fuelTime)
  216. statusInside.setTextColor(colors.white)
  217. statusInside.write(" Secs")
  218.  
  219.  
  220.  
  221. --Author Box
  222. authorBox = window.create(term.current(),4,28,8,1)
  223. paintutils.drawBox(2,28,47,37,colors.gray)
  224. authorBox.setBackgroundColor(colors.black)
  225. authorBox.setTextColor(colors.blue)
  226. authorBox.setCursorPos(1,1)
  227. authorBox.write(" Author ")
  228. authorImg = paintutils.loadImage("author.nfp")
  229. paintutils.drawImage(authorImg,3,29)
  230.  
  231. sleep(0.1)
  232.  
  233. end
  234. end
  235. while true do
  236.  
  237. parallel.waitForAny(touchLoc,main_loop)
  238.  
  239. --Manual Override
  240. manOver = withinBox(66,4,75,6)
  241. if manOver == true then
  242.     MO = MO + 1
  243. else
  244.     MO = MO
  245. end
  246.  
  247. if (MO % 2 == 0) then
  248. manOver = colors.green
  249. overrideStatus = "Enabled "
  250. override = true
  251. else
  252. manOver = colors.red
  253. overrideStatus = "Disabled"
  254. override = false
  255. end
  256.  
  257. onBox = withinBox(52,8,61,10)
  258.  
  259. if onBox == true and override == true then
  260. r.setActive(true)
  261. end
  262.  
  263. offBox = withinBox(66,8,75,10)
  264.  
  265. if offBox == true and override == true then
  266. r.setActive(false)
  267. end
  268.  
  269. if override == false then
  270. autoReactor()
  271. end
  272.  
  273. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement