Advertisement
IGN_Mikey

CC Controls Big Reactor (Portrait)

May 6th, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.38 KB | None | 0 0
  1. --
  2. -- Project: ComputCraft controlling Big Reactor
  3. -- Version: 1.9
  4. -- Description:
  5. --
  6. -- Managed by MikeyLikeyMC
  7. -- Tutorials available here: http://bit.ly/1IgK6cA
  8. --
  9. -- Copyright 2015 . All Rights Reserved.
  10. --
  11. print('Welcome to IGN Power Control...')
  12. print('')
  13. sleep(0.5)
  14. print('Brought to you by: MikeyLikeyMC')
  15. print('')
  16. sleep(0.5)
  17. print('Please wait ...')
  18. print('')
  19. sleep(1)
  20. print('ReactorControl has been Engaged.')
  21. print('Please view main Monitor.')
  22. print('')
  23.  
  24. -- Peripheral Locations
  25. reactor=peripheral.wrap('back')
  26. monitor=peripheral.wrap('top')
  27.  
  28. -- Reactor Variables
  29. emptyflag=0
  30. offlineflag=0
  31.  
  32. -- Flashing Message
  33. -- Will also need to unmute other lines of code in the warning area to re-enable
  34.  
  35. -- flashflag=0 -- Muted to prevent the flashing
  36.  
  37. -- Formating Variables
  38. newSection = 2 -- AKA Double Space
  39. nextLine = 1
  40.  
  41. cellA = 0 -- Can be used to ensure a border
  42. cellB = 3 -- Can be used to indent information for easy readability
  43. cellC = 12 -- Data lined up with center of 3 x 4 monitor
  44.  
  45. -- Definable Colors
  46. background = (colors.black) -- Monitor Background
  47. sectionHeader = (colors.white) -- Monitor Colors
  48. header = (colors.white)
  49.  
  50. -- Temperatures
  51. fuel = (colors.yellow)
  52. waste = (colors.cyan)
  53. producing = (colors.green) -- Amount of power being produced (reference: RF)
  54. casing = (colors.lightGray)
  55. steam = (colors.blue)
  56. safe = (colors.green)
  57. neutral = (colors.orange)
  58. danger = (colors.red)
  59. credits = (colors.cyan)
  60.  
  61. -- Automation Formatting & Messages (These Override the Definable Colors above)
  62. fManualOverride = (colors.lightGray)
  63. mManualOverride = (' OFFLINE (Manual Override)')
  64. -- Simplified: OFFLINE: Manual Override
  65.  
  66. fFuelExhausted = (colors.pink)
  67. mManualOverride = (' OFFLINE (Fuel Exhausted)')
  68. -- Simplified: OFFLINE: Fuel Exhausted
  69.  
  70. fLowPowerMode = (colors.purple)
  71. mLowPowerMode = ('  ONLINE (Low Power Mode)')
  72. -- Simplified: ONLINE: Low Power Mode
  73.  
  74. fHighPowerMode = (colors.orange)
  75. mHighPowerMode = ('  ONLINE (High Power Mode)')
  76. -- Simplified: ONLINE: High Power Mode
  77.  
  78.  
  79. -- Peripheral Locations
  80. reactor=peripheral.wrap('back')
  81. monitor=peripheral.wrap('top')
  82.  
  83. monitor.setTextScale(1)
  84. monitor.setBackgroundColor(background)
  85.  
  86. while true do
  87. -- Refreshes the screen and resets the cursor positions to their defaults
  88. x=1
  89. y=1
  90. monitor.clear()
  91. monitor.setCursorPos(x+cellA,y)
  92. monitor.setTextColor(header)
  93. monitor.write('Fuel Level:')
  94. y=y+1
  95. monitor.setCursorPos(x+cellB,y)
  96. monitor.setTextColor(fuel)
  97. monitor.write(math.floor(((reactor.getFuelAmount()/reactor.getFuelAmountMax())*100)+0.5)..'% Fuel')
  98. -- No increment to y (same line)
  99. monitor.setCursorPos(x+cellC,y)
  100. monitor.setTextColor(waste)
  101. monitor.write(math.floor(((reactor.getWasteAmount()/reactor.getFuelAmountMax())*100)+0.5)..'% Waste')
  102.  
  103. y=y+newSection
  104. monitor.setCursorPos(x,y)
  105. monitor.setTextColor(header)
  106. monitor.write('Control Rod Levels (TBS):')
  107. monitor.setTextColor(neutral)
  108. y=y+1
  109. monitor.setCursorPos(x+cellB,y)
  110. monitor.write('  Rod 1: '..(100-(reactor.getControlRodLevel(0)))..'% Depth')
  111. y=y+1
  112. monitor.setCursorPos(x+cellB,y)
  113. monitor.write('  Rod 2: '..(100-(reactor.getControlRodLevel(1)))..'% Depth')
  114. y=y+1
  115. monitor.setCursorPos(x+cellB,y)
  116. monitor.write('  Rod 3: '..(100-(reactor.getControlRodLevel(2)))..'% Depth')
  117. y=y+1
  118. monitor.setCursorPos(x+cellB,y)
  119. monitor.write('  Rod 4: '..(100-(reactor.getControlRodLevel(3)))..'% Depth')
  120. y=y+1
  121. monitor.setCursorPos(x+cellB,y)
  122. monitor.write('  Rod 5: '..(100-(reactor.getControlRodLevel(4)))..'% Depth')
  123.  
  124. y=y+newSection
  125. monitor.setCursorPos(x+cellA,y)
  126. monitor.setTextColor(sectionHeader)
  127. monitor.write('Temperature:')
  128. y=y+1
  129. monitor.setCursorPos(x+cellB,y)
  130. monitor.setTextColor(casing)
  131. monitor.write(' Casing: ')
  132. if reactor.getCasingTemperature()>=650 then
  133.     monitor.setTextColor(neutral)
  134.     else if reactor.getCasingTemperature()>=950 then
  135.         monitor.setTextColor(danger)
  136.     else
  137.         monitor.setTextColor(safe)
  138.     end
  139. end
  140. monitor.setCursorPos(x+cellC,y)
  141. monitor.write(reactor.getCasingTemperature()..'C')
  142.  
  143. y=y+1
  144. monitor.setCursorPos(x+cellB,y)
  145. monitor.setTextColor(fuel)
  146. monitor.write('   Fuel: ')
  147. if reactor.getFuelTemperature()>=650 then
  148.   monitor.setTextColor(neutral)
  149.   else if reactor.getFuelTemperature()>=950 then
  150.     monitor.setTextColor(danger)
  151.   else
  152.  monitor.setTextColor(safe)
  153.   end
  154. end
  155. monitor.setCursorPos(x+cellC,y)
  156. monitor.write(reactor.getFuelTemperature()..'C')
  157.  
  158. y=y+newSection
  159. monitor.setCursorPos(x+cellB,y)
  160. monitor.setTextColor(header)
  161. monitor.write('   Flux:')
  162. --Same Line
  163. monitor.setCursorPos(x+cellC,y) -- if re-enabled a new cell may need to be defined
  164. monitor.setTextColor(safe)
  165. monitor.write(reactor.getEnergyStored()..' RF Stored')
  166.  
  167. y=y+newSection
  168. monitor.setCursorPos(x+cellA,y)
  169. monitor.setTextColor(header)
  170. monitor.write(' Producing: ')
  171. --Same Line
  172. -- monitor.setCursorPos(x+cellC,y)
  173. monitor.setTextColor(safe)
  174.  
  175. if reactor.getEnergyProducedLastTick()>=500 and reactor.getEnergyProducedLastTick()<2000 then
  176.     monitor.setTextColor(neutral)
  177. end
  178.  
  179. if reactor.getEnergyProducedLastTick()>=2000 then
  180.     monitor.setTextColor(danger)
  181. end
  182. monitor.setTextColor(producing)
  183. monitor.write((math.floor(reactor.getEnergyProducedLastTick()+0.5))..' RF/t')
  184.  
  185. y=y+newSection
  186. monitor.setCursorPos(x+cellA,y)
  187. monitor.setTextColor(sectionHeader)
  188. monitor.write('Automation:')
  189.  
  190. --if flashflag==0 then
  191. --  flashflag=1
  192. y=y+1
  193.   if offlineflag==1 then
  194.     monitor.setCursorPos(x+cellB,y)
  195.     monitor.setTextColor(fManualOverride) -- Default: lightGray
  196.     monitor.write(mManualOverride)
  197.   end
  198.   if emptyflag==1 then
  199.     monitor.setCursorPos(x+cellB,y)
  200.     monitor.setTextColor(fFuelExhausted) -- Default: pink
  201.     monitor.write(mFuelExhausted)
  202.   end
  203.   if emptyflag==0 and offlineflag==0 and reactor.getControlRodLevel(0)>75 then
  204.     monitor.setCursorPos(x+cellB,y)
  205.     monitor.setTextColor(fLowPowerMode) -- Default: purple
  206.     monitor.write(mLowPowerMode)
  207.   end
  208.   if emptyflag==0 and offlineflag==0 and reactor.getControlRodLevel(0)<=75 then
  209.     monitor.setCursorPos(x+cellB,y)
  210.     monitor.setTextColor(fHighPowerMode)
  211.     monitor.write(mHighPowerMode)
  212.   end
  213. --else
  214. --  flashflag=0
  215. --  monitor.setCursorPos(1,23) --- Is this line necessary if not using Flashing?
  216. --  monitor.clearLine()
  217. --end
  218.  
  219.  
  220. --  *****************************************
  221. --  *                                       *
  222. --  *  Out of respect for the coder please  *
  223. --  *  do not change the following credits  *
  224. --  *                                       *
  225. --  *****************************************
  226.  
  227.  
  228. y=y+newSection
  229. monitor.setCursorPos(x+cellA+2,25)
  230. monitor.setTextColor(header)
  231. monitor.write('Your IT Specialist:')
  232. y=y+1
  233. monitor.setCursorPos(x+15,26) -- Indentation
  234. monitor.setTextColor(credits)
  235. monitor.write('MikeyLikeyMC')
  236.  
  237. if reactor.getEnergyStored()<=10000000 and reactor.getEnergyStored()>100 then
  238.     reactor.setAllControlRodLevels(0+(math.floor(reactor.getEnergyStored()/100000)))
  239. else
  240.     reactor.setAllControlRodLevels(0)
  241. end
  242.  
  243. if reactor.getFuelAmount()<=100 and offlineflag==0 then
  244.     reactor.setAllControlRodLevels(100)
  245.     reactor.setActive(false)
  246.     emptyflag=1
  247. else
  248.     emptyflag=0
  249. end
  250.      
  251. if rs.getInput('bottom')==false and emptyflag==0 then
  252.     reactor.setActive(true)
  253.     offlineflag=0
  254. end
  255.  
  256. if rs.getInput('bottom')==true and emptyflag==0 then
  257.     reactor.setActive(false)
  258.     reactor.setAllControlRodLevels(100)
  259.     offlineflag=1
  260. end
  261. sleep(1)
  262. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement