View difference between Paste ID: JRM2vwgp and qN8phrfG
SHOW: | | - or go back to the newest paste.
1
--Initialize Variables
2
3
local reactor
4
local monitor
5
local State
6
local Temp
7
local Fuel
8
local Waste
9
emptyflag=0
10
offlineflag=0
11
flashflag=0
12
13
turbine1 = peripheral.wrap("BigReactors-Turbine_1")
14
turbine2 = peripheral.wrap("BigReactors-Turbine_2")
15
turbine3 = peripheral.wrap("BigReactors-Turbine_3")
16
reactor = peripheral.wrap("back")
17
monitor = peripheral.wrap("monitor_2")
18
19
monitor.setTextScale(1)
20
monitor.setBackgroundColor(colors.black)
21
22
--Functions
23
24
function wipeScreen()
25
   term.clear()
26
   term.setCursorPos(1, 1)
27
end
28
29
function delayPrint(pause,msg)
30
   print(msg)
31
   sleep(pause)
32
end
33
34
--Program
35
36
wipeScreen()
37
print("System Control Startup")
38
sleep(1)
39
while true do
40
 reactor.getConnected()
41
 
42
monitor.clear()
43
 monitor.setCursorPos(9,1)
44
 monitor.setTextColor(colors.white)
45
 monitor.write('Reactor System Monitor')
46
 monitor.setCursorPos(1,2)
47
 monitor.write('Fuel Level:')
48
 monitor.setCursorPos(1,3)
49
 monitor.setTextColor(colors.yellow)
50
 monitor.write(math.floor((((reactor.getFuelAmount())/(reactor.getFuelAmountMax()))*100)+0.5)..'% Fuel')
51
 monitor.setCursorPos(1,4)
52
 monitor.setTextColor(colors.lightBlue)
53
 monitor.write(math.floor((((reactor.getWasteAmount())/(reactor.getFuelAmountMax()))*100)+0.5)..'% Waste')
54
 
55
 monitor.setCursorPos(15,2)
56
monitor.setTextColor(colors.white)
57
monitor.write('Steam:')
58
monitor.setCursorPos(13,3)
59
monitor.setTextColor(colors.green)
60
61
62
if reactor.getHotFluidAmount()>=30000 and reactor.getHotFluidAmount()<20000 then
63
    monitor.setTextColor(colors.orange)
64
end
65
 
66
if reactor.getHotFluidAmount()>=40000 then
67
    monitor.setTextColor(colors.red)
68
end
69
70
monitor.write('Steam Pressure: '..reactor.getHotFluidAmount()..' mb')
71
72
monitor.setCursorPos(13,3)
73
monitor.write('       Outlet: '..reactor.getEnergyProducedLastTick()..' mb/t')
74
 
75
 
76
 monitor.setCursorPos(1,6)
77
 monitor.setTextColor(colors.white)
78
  monitor.setTextColor(colors.white)
79
 monitor.write('Temperature:')
80
 monitor.setCursorPos(1,7)
81
  if reactor.getFuelTemperature()>=650 then
82
    monitor.setTextColor(colors.purple)
83
    elseif reactor.getFuelTemperature()>=1000 then
84
        monitor.setTextColor(colors.red)
85
    else
86
        monitor.setTextColor(colors.green)
87
    end
88
 end
89
 monitor.write('Fuel: '..reactor.getFuelTemperature()..'C   Casing: '..reactor.getCasingTemperature()..'C')
90
 
91
 monitor.setCursorPos(40,2)
92
 monitor.setTextColor(colors.white)
93
 monitor.write('Turbine 1 Status')
94
 monitor.setCursorPos(40,3)
95
 if turbine1.getFluidFlowRate()>=1999 then
96
  monitor.setTextColor(colors.green)
97
  elseif turbine1.getFluidFlowRate()>=1500 then
98
   monitor.setTextColor(colors.orange)
99
  else
100
   monitor.setTextColor(colors.red)
101
  end
102
  monitor.write('Flow Rate: '..turbine1.getFluidFlowRate()..'mb/t')
103
  
104
monitor.setCursorPos(40,4)
105
if turbine1.getRotorSpeed()>=1700 and turbine1.getRotorSpeed()<=1900 then
106
 monitor.setTextColor(colors.green)  
107
 else
108
 monitor.setTextColor(colors.red)
109
 end
110
 
111
monitor.write('Rotor Speed: '..turbine1.getRotorSpeed()..' rpm')
112
113
monitor.setCursorPos(40,5)
114
if turbine1.getEnergyProducedLastTick()>= 25000 then
115
 monitor.setTextColor(colors.green)
116
 else
117
 monitor.setTextColor(colors.red)
118
 end
119
monitor.write('Generation: '..turbine1.getEnergyProducedLastTick()..' rf/t')
120
121
 monitor.setCursorPos(40,7)
122
 monitor.setTextColor(colors.white)
123
 monitor.write('Turbine 2 Status')
124
 monitor.setCursorPos(40,8)
125-
 if turbine2.getFluidFlowRate()=2000 then
125+
 if turbine2.getFluidFlowRate()>=1999 then
126
  monitor.setTextColor(colors.green)
127
  elseif turbine2.getFluidFlowRate()>=1500 then
128
   monitor.setTextColor(colors.orange)
129
  else
130
   monitor.setTextColor(colors.red)
131
  end
132
  monitor.write('Flow Rate: '..turbine2.getFluidFlowRate()..'mb/t')
133
  
134
monitor.setCursorPos(40,9)
135
if turbine2.getRotorSpeed()>=1700 and turbine2.getRotorSpeed()<=1900 then
136
 monitor.setTextColor(colors.green)  
137
 else
138
 monitor.setTextColor(colors.red)
139
 end
140
 
141
monitor.write('Rotor Speed: '..turbine2.getRotorSpeed()..' rpm')
142
143
monitor.setCursorPos(40,10)
144
if turbine2.getEnergyProducedLastTick()>= 25000 then
145
 monitor.setTextColor(colors.green)
146
 else
147
 monitor.setTextColor(colors.red)
148
 end
149
monitor.write('Generation: '..turbine2.getEnergyProducedLastTick()..' rf/t')
150
151
 monitor.setCursorPos(40,12)
152
 monitor.setTextColor(colors.white)
153
 monitor.write('Turbine 3 Status')
154
 monitor.setCursorPos(40,13)
155-
 if turbine3.getFluidFlowRate()=2000 then
155+
 if turbine3.getFluidFlowRate()>=1999 then
156
  monitor.setTextColor(colors.green)
157
  elseif turbine3.getFluidFlowRate()>=1500 then
158
   monitor.setTextColor(colors.orange)
159
  else
160
   monitor.setTextColor(colors.red)
161
  end
162
  monitor.write('Flow Rate: '..turbine3.getFluidFlowRate()..'mb/t')
163
  
164
monitor.setCursorPos(40,14)
165
if turbine3.getRotorSpeed()>=1700 and turbine3.getRotorSpeed()<=1900 then
166
 monitor.setTextColor(colors.green)  
167
 else
168
 monitor.setTextColor(colors.red)
169
 end
170
 
171
monitor.write('Rotor Speed: '..turbine3.getRotorSpeed()..' rpm')
172
173
monitor.setCursorPos(40,15)
174
if turbine3.getEnergyProducedLastTick()>= 25000 then
175
 monitor.setTextColor(colors.green)
176
 else
177
 monitor.setTextColor(colors.red)
178
 end
179
monitor.write('Generation: '..turbine3.getEnergyProducedLastTick()..' rf/t')
180
181
monitor.setCursorPos(40,17)
182
monitor.setTextColor(colors.white)
183
monitor.write('Capacitor Banks:')
184
185
monitor.setCursorPos(40,18)
186
if turbine1.getEnergyStored()>=9900000 then
187
 monitor.setTextColor(colors.red)
188
 else
189
 monitor.setTextColor(colors.green)
190
end
191
monitor.write('Turbine 1: '..turbine1.getEnergyStored()..' RF')
192
193
monitor.setCursorPos(40,19)
194
if turbine2.getEnergyStored()>=9900000 then
195
 monitor.setTextColor(colors.red)
196
 else
197
 monitor.setTextColor(colors.green)
198
end
199
monitor.write('Turbine 2: '..turbine2.getEnergyStored()..' RF')
200
201
monitor.setCursorPos(40,18)
202
if turbine3.getEnergyStored()>=9900000 then
203
 monitor.setTextColor(colors.red)
204
 else
205
 monitor.setTextColor(colors.green)
206
end
207
monitor.write('Turbine 3: '..turbine3.getEnergyStored()..' RF')
208
 
209
 
210
 
211
 monitor.setCursorPos(1,9)
212
 monitor.setTextColor(colors.white)
213
 monitor.write('Control Rod Levels:')
214
 monitor.setTextColor(colors.green)
215
 monitor.setCursorPos(1,10)
216
 monitor.write('Rods  1-24:  '..(100-(reactor.getControlRodLevel(0)))..'%')
217
 
218
 monitor.setCursorPos(20,10)
219
 monitor.write('Rods   24-48:  '..(100-(reactor.getControlRodLevel(1)))..'%')
220
 
221
 monitor.setCursorPos(1,11)
222
 monitor.write('Rods 72-96:  '..(100-(reactor.getControlRodLevel(2)))..'%')
223
 
224
 monitor.setCursorPos(20,11)
225
 monitor.write('Rods 120-144:  '..(100-(reactor.getControlRodLevel(3)))..'%')
226
 
227
 monitor.setCursorPos(1,14)
228
 monitor.setTextColor(colors.white)
229
 monitor.write('Reactor Radioactivity')
230
 
231
 monitor.setCursorPos(24,14)
232
 monitor.write('Fuel Usage')
233
 
234
 monitor.setTextColor(colors.green)
235
 monitor.setCursorPos(1,15)
236
 monitor.write(''..reactor.getFuelReactivity()..'%')
237
 monitor.setCursorPos(24,15)
238
 monitor.write(''..reactor.getFuelConsumedLastTick()..' mb/t')
239
 
240
 monitor.setCursorPos(1,16)
241
monitor.setTextColor(colors.orange)
242
monitor.write('Status:')
243
 
244
if flashflag==0 then
245
  flashflag=1
246
  if offlineflag==1 then
247
    monitor.setCursorPos(1,17)
248
    monitor.setTextColor(colors.lightGray)
249
    monitor.write('OFFLINE - Manual Override')
250
  end
251
  if emptyflag==1 then
252
    monitor.setCursorPos(1,17)
253
    monitor.setTextColor(colors.pink)
254
    monitor.write('OFFLINE - Fuel Exhausted')
255
  end
256
  if emptyflag==0 and offlineflag==0 and reactor.getControlRodLevel(0)>75 then
257
    monitor.setCursorPos(1,17)
258
    monitor.setTextColor(colors.yellow)
259
    monitor.write('ONLINE - Low Power Mode')
260
  end
261
  if emptyflag==0 and offlineflag==0 and reactor.getControlRodLevel(0)<=75 then
262
    monitor.setCursorPos(1,17)
263
    monitor.setTextColor(colors.orange)
264
    monitor.write('ONLINE - High Power Mode')
265
  end
266
else
267
  flashflag=0
268
  monitor.setCursorPos(1,17)
269
  monitor.clearLine()
270
end
271
272
273
274
275
if reactor.getEnergyProducedLastTick<=5999 then
276
    reactor.setAllControlRodLevels(0+(math.floor(reactor.getEnergyProducedLastTick()/6000)))
277
278
elseif reactor.getEnergyProducedLastTick()>=6000 then
279
	reactor.setAllControlRodLevels(100)
280
else
281
	reactor.setAllControlRodLevels(0)
282
end
283
284
if (reactor.getFuelAmount()<=100) and offlineflag==0 then
285
    reactor.setAllControlRodLevels(100)
286
    reactor.setActive(false)
287
    emptyflag=1
288
else
289
    emptyflag=0
290
end
291
292
if rs.getInput('bottom')==false and emptyflag==0 then
293
    reactor.setActive(true)
294
    offlineflag=0
295
end
296
297
if rs.getInput('bottom')==true and emptyflag==0 then
298
    reactor.setActive(false)
299
    reactor.setAllControlRodLevels(100)
300
    offlineflag=1
301
end    
302
sleep(1)
303
end