Advertisement
Guest User

startup

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