View difference between Paste ID: FUdbKAXD and czBLRkUb
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
sleep(1)
41
 reactor.getConnected()
42
 
43
monitor.clear()
44
 monitor.setCursorPos(9,1)
45
 monitor.setTextColor(colors.white)
46
 monitor.write('Reactor System Monitor')
47
 monitor.setCursorPos(1,2)
48
 monitor.write('Fuel Level:')
49
 monitor.setCursorPos(1,3)
50
 monitor.setTextColor(colors.yellow)
51
 monitor.write(math.floor((((reactor.getFuelAmount())/(reactor.getFuelAmountMax()))*100)+0.5)..'% Fuel')
52
 monitor.setCursorPos(1,4)
53
 monitor.setTextColor(colors.lightBlue)
54
 monitor.write(math.floor((((reactor.getWasteAmount())/(reactor.getFuelAmountMax()))*100)+0.5)..'% Waste')
55
 
56
 monitor.setCursorPos(15,2)
57
monitor.setTextColor(colors.white)
58
monitor.write('Steam:')
59
monitor.setCursorPos(13,3)
60
monitor.setTextColor(colors.green)
61
62
63
if reactor.getHotFluidAmount()>=30000 and reactor.getHotFluidAmount()<20000 then
64
    monitor.setTextColor(colors.orange)
65
end
66
67
if reactor.getHotFluidAmount()>=40000 then
68
    monitor.setTextColor(colors.red)
69
end
70
71
monitor.write('Steam Pressure: '..reactor.getHotFluidAmount()..' mb')
72
73
monitor.setCursorPos(13,3)
74
monitor.write('       Outlet: '..reactor.getEnergyProducedLastTick()..' mb/t')
75
 
76
 
77
 monitor.setCursorPos(1,6)
78
 monitor.setTextColor(colors.white)
79
  monitor.setTextColor(colors.white)
80
 monitor.write('Temperature:')
81
 monitor.setCursorPos(1,7)
82
  if reactor.getFuelTemperature()>=650 then
83
    monitor.setTextColor(colors.purple)
84
    elseif reactor.getFuelTemperature()>=1000 then
85
        monitor.setTextColor(colors.red)
86
    else
87
        monitor.setTextColor(colors.green)
88
  end
89
	
90
 monitor.write('Fuel: '..reactor.getFuelTemperature()..'C   Casing: '..reactor.getCasingTemperature()..'C')
91
 
92
 
93
 monitor.setCursorPos(40,1)
94
 monitor.setTextColor(colors.white)
95
if (turbine1.getConnected()) then
96
 
97
98
 monitor.write('Turbine 1 Status')
99
 monitor.setCursorPos(40,2)
100
 if turbine1.getFluidFlowRate()>=1999 then
101
  monitor.setTextColor(colors.green)
102
  elseif turbine1.getFluidFlowRate()>=1500 then
103
   monitor.setTextColor(colors.orange)
104
  else
105
   monitor.setTextColor(colors.red)
106
 end
107
 
108
  monitor.write('Flow Rate: '..turbine1.getFluidFlowRate()..'mb/t')
109
  
110
monitor.setCursorPos(40,3)
111
if turbine1.getRotorSpeed()>=1700 and turbine1.getRotorSpeed()<=1900 then
112
 monitor.setTextColor(colors.green)  
113
 else
114
 monitor.setTextColor(colors.red)
115
end
116
 
117
 
118
monitor.write('Rotor Speed: '..turbine1.getRotorSpeed()..' rpm')
119
120
monitor.setCursorPos(40,4)
121
if turbine1.getEnergyProducedLastTick()>= 25000 then
122
 monitor.setTextColor(colors.green)
123
 else
124
 monitor.setTextColor(colors.red)
125
end
126
127
monitor.write('Generation: '..turbine1.getEnergyProducedLastTick()..' rf/t')
128
129
else
130
return nil
131
monitor.setTextColor(colors.red)
132
monitor.write('Turbine 1 Disconnected From SYS')
133
end
134
135
 monitor.setCursorPos(40,6)
136
 monitor.setTextColor(colors.white)
137
if (turbine2.getConnected()) then
138
  
139
 monitor.write('Turbine 2 Status')
140
 monitor.setCursorPos(40,7)
141
 if turbine2.getFluidFlowRate()>=1999 then
142
  monitor.setTextColor(colors.green)
143
  elseif turbine2.getFluidFlowRate()>=1500 then
144
   monitor.setTextColor(colors.orange)
145
  else
146
   monitor.setTextColor(colors.red)
147
 end
148
  monitor.write('Flow Rate: '..turbine2.getFluidFlowRate()..'mb/t')
149
  
150
monitor.setCursorPos(40,8)
151
if turbine2.getRotorSpeed()>=1700 and turbine2.getRotorSpeed()<=1900 then
152
 monitor.setTextColor(colors.green)  
153
 else
154
 monitor.setTextColor(colors.red)
155
end
156
 
157
monitor.write('Rotor Speed: '..turbine2.getRotorSpeed()..' rpm')
158
159
monitor.setCursorPos(40,9)
160
if turbine2.getEnergyProducedLastTick()>= 25000 then
161
 monitor.setTextColor(colors.green)
162
 else
163
 monitor.setTextColor(colors.red)
164
end
165
monitor.write('Generation: '..turbine2.getEnergyProducedLastTick()..' rf/t')
166
167
else
168
monitor.setTextColor(colors.red)
169
monitor.write('Turbine 2 Disconnected From SYS')
170
end
171
172
 monitor.setCursorPos(40,11)
173
 monitor.setTextColor(colors.white)
174
 
175
 if (turbine3.getConnected()) then
176
 
177
 monitor.write('Turbine 3 Status')
178
 monitor.setCursorPos(40,12)
179
 if turbine3.getFluidFlowRate()>=1999 then
180
  monitor.setTextColor(colors.green)
181
  elseif turbine3.getFluidFlowRate()>=1500 then
182
   monitor.setTextColor(colors.orange)
183
  else
184
   monitor.setTextColor(colors.red)
185
 end
186
  monitor.write('Flow Rate: '..turbine3.getFluidFlowRate()..'mb/t')
187
  
188
monitor.setCursorPos(40,13)
189
if turbine3.getRotorSpeed()>=1700 and turbine3.getRotorSpeed()<=1900 then
190
 monitor.setTextColor(colors.green)  
191
 else
192
 monitor.setTextColor(colors.red)
193
end
194
 
195
monitor.write('Rotor Speed: '..turbine3.getRotorSpeed()..' rpm')
196
197
monitor.setCursorPos(40,14)
198
if turbine3.getEnergyProducedLastTick()>= 25000 then
199
 monitor.setTextColor(colors.green)
200
 else
201
 monitor.setTextColor(colors.red)
202
end
203
monitor.write('Generation: '..turbine3.getEnergyProducedLastTick()..' rf/t')
204
205
else
206
 monitor.setTextColor(colors.red)
207
monitor.write('Turbine 3 Disconnected From SYS')
208
end
209
210
monitor.setCursorPos(40,16)
211
monitor.setTextColor(colors.white)
212
monitor.write('Capacitor Banks:')
213
214
if (turbine1.getConnected()) then
215
monitor.setCursorPos(40,17)
216
if turbine1.getEnergyStored()>=9900000 then
217
 monitor.setTextColor(colors.red)
218
 else
219
 monitor.setTextColor(colors.green)
220
end
221
monitor.write('Turbine 1: '..turbine1.getEnergyStored()..' RF')
222
else
223
return nil
224
end
225
226
if (turbine2.getConnected()) then
227
monitor.setCursorPos(40,18)
228
if turbine2.getEnergyStored()>=9900000 then
229
 monitor.setTextColor(colors.red)
230
 else
231
 monitor.setTextColor(colors.green)
232
end
233
monitor.write('Turbine 2: '..turbine2.getEnergyStored()..' RF')
234
end
235
236
if (turbine3.getConnected()) then
237
monitor.setCursorPos(40,19)
238
if turbine3.getEnergyStored()>=9900000 then
239
 monitor.setTextColor(colors.red)
240
 else
241
 monitor.setTextColor(colors.green)
242
end
243
monitor.write('Turbine 3: '..turbine3.getEnergyStored()..' RF')
244
end
245
 
246
 
247
 
248
 monitor.setCursorPos(1,9)
249
 monitor.setTextColor(colors.white)
250
 monitor.write('Control Rod Levels:')
251
 monitor.setTextColor(colors.green)
252
 monitor.setCursorPos(1,10)
253
 monitor.write('Rods  1-24:  '..(100-(reactor.getControlRodLevel(0)))..'%')
254
 
255
 monitor.setCursorPos(20,10)
256
 monitor.write('Rods   24-48:  '..(100-(reactor.getControlRodLevel(1)))..'%')
257
 
258
 monitor.setCursorPos(1,11)
259
 monitor.write('Rods 72-96:  '..(100-(reactor.getControlRodLevel(2)))..'%')
260
 
261
 monitor.setCursorPos(20,11)
262
 monitor.write('Rods 120-144:  '..(100-(reactor.getControlRodLevel(3)))..'%')
263
 
264
 monitor.setCursorPos(1,14)
265
 monitor.setTextColor(colors.white)
266
 monitor.write('Reactor Radioactivity')
267
 
268
 monitor.setCursorPos(24,14)
269
 monitor.write('Fuel Usage')
270
 
271
 monitor.setTextColor(colors.green)
272
 monitor.setCursorPos(1,15)
273
 monitor.write(''..reactor.getFuelReactivity()..'%')
274
 monitor.setCursorPos(24,15)
275
 monitor.write(''..reactor.getFuelConsumedLastTick()..' mb/t')
276
 
277
 monitor.setCursorPos(1,16)
278
monitor.setTextColor(colors.orange)
279
monitor.write('Status:')
280
 
281
if flashflag==0 then
282
  flashflag=1
283
  if offlineflag==1 then
284
    monitor.setCursorPos(1,17)
285
    monitor.setTextColor(colors.lightGray)
286
    monitor.write('OFFLINE - Manual Override')
287
  end
288
  if emptyflag==1 then
289
    monitor.setCursorPos(1,17)
290
    monitor.setTextColor(colors.pink)
291
    monitor.write('OFFLINE - Fuel Exhausted')
292
  end
293
  if emptyflag==0 and offlineflag==0 and reactor.getControlRodLevel(0)>75 then
294
    monitor.setCursorPos(1,17)
295
    monitor.setTextColor(colors.yellow)
296
    monitor.write('ONLINE - Low Power Mode')
297
  end
298
  if emptyflag==0 and offlineflag==0 and reactor.getControlRodLevel(0)<=75 then
299
    monitor.setCursorPos(1,17)
300
    monitor.setTextColor(colors.orange)
301
    monitor.write('ONLINE - High Power Mode')
302
  end
303
else
304
  flashflag=0
305
end
306
307
308
309
310
if reactor.getEnergyProducedLastTick()<=5999 then
311
    reactor.setAllControlRodLevels(0+(math.floor(reactor.getEnergyProducedLastTick()/6000)))
312
313
elseif reactor.getEnergyProducedLastTick()>=6000 then
314
	reactor.setAllControlRodLevels(100)
315
else
316
	reactor.setAllControlRodLevels(0)
317
end
318
319
if (reactor.getFuelAmount()<=100) and offlineflag==0 then
320
    reactor.setAllControlRodLevels(100)
321
    reactor.setActive(false)
322
    emptyflag=1
323
else
324
    emptyflag=0
325
end
326
327
if rs.getInput('bottom')==false and emptyflag==0 then
328
    reactor.setActive(true)
329
    offlineflag=0
330
end
331
332
if rs.getInput('bottom')==true and emptyflag==0 then
333
    reactor.setActive(false)
334
    reactor.setAllControlRodLevels(100)
335
    offlineflag=1
336
end    
337
sleep(0)
338
end