View difference between Paste ID: HzTx5czh and nJRedxPE
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
 monitor.setCursorPos(40,2)
93
 monitor.setTextColor(colors.white)
94
 monitor.write('Turbine 1 Status')
95
 monitor.setCursorPos(40,3)
96
 if turbine1.getFluidFlowRate()>=1999 then
97
  monitor.setTextColor(colors.green)
98
  elseif turbine1.getFluidFlowRate()>=1500 then
99
   monitor.setTextColor(colors.orange)
100
  else
101
   monitor.setTextColor(colors.red)
102
 end
103
 
104
  monitor.write('Flow Rate: '..turbine1.getFluidFlowRate()..'mb/t')
105
  
106
monitor.setCursorPos(40,4)
107
if turbine1.getRotorSpeed()>=1700 and turbine1.getRotorSpeed()<=1900 then
108
 monitor.setTextColor(colors.green)  
109
 else
110
 monitor.setTextColor(colors.red)
111
end
112
 
113
 
114
monitor.write('Rotor Speed: '..turbine1.getRotorSpeed()..' rpm')
115
116
monitor.setCursorPos(40,5)
117
if turbine1.getEnergyProducedLastTick()>= 25000 then
118
 monitor.setTextColor(colors.green)
119
 else
120
 monitor.setTextColor(colors.red)
121
end
122
123
monitor.write('Generation: '..turbine1.getEnergyProducedLastTick()..' rf/t')
124
125
 monitor.setCursorPos(40,7)
126
 monitor.setTextColor(colors.white)
127
 monitor.write('Turbine 2 Status')
128
 monitor.setCursorPos(40,8)
129
 if turbine2.getFluidFlowRate()>=1999 then
130
  monitor.setTextColor(colors.green)
131
  elseif turbine2.getFluidFlowRate()>=1500 then
132
   monitor.setTextColor(colors.orange)
133
  else
134
   monitor.setTextColor(colors.red)
135
 end
136
  monitor.write('Flow Rate: '..turbine2.getFluidFlowRate()..'mb/t')
137
  
138
monitor.setCursorPos(40,9)
139
if turbine2.getRotorSpeed()>=1700 and turbine2.getRotorSpeed()<=1900 then
140
 monitor.setTextColor(colors.green)  
141
 else
142
 monitor.setTextColor(colors.red)
143
end
144
 
145
monitor.write('Rotor Speed: '..turbine2.getRotorSpeed()..' rpm')
146
147
monitor.setCursorPos(40,10)
148
if turbine2.getEnergyProducedLastTick()>= 25000 then
149
 monitor.setTextColor(colors.green)
150
 else
151
 monitor.setTextColor(colors.red)
152
end
153
monitor.write('Generation: '..turbine2.getEnergyProducedLastTick()..' rf/t')
154
155
 monitor.setCursorPos(40,12)
156
 monitor.setTextColor(colors.white)
157
 monitor.write('Turbine 3 Status')
158
 monitor.setCursorPos(40,13)
159
 if turbine3.getFluidFlowRate()>=1999 then
160
  monitor.setTextColor(colors.green)
161
  elseif turbine3.getFluidFlowRate()>=1500 then
162
   monitor.setTextColor(colors.orange)
163
  else
164
   monitor.setTextColor(colors.red)
165
 end
166
  monitor.write('Flow Rate: '..turbine3.getFluidFlowRate()..'mb/t')
167
  
168
monitor.setCursorPos(40,14)
169
if turbine3.getRotorSpeed()>=1700 and turbine3.getRotorSpeed()<=1900 then
170
 monitor.setTextColor(colors.green)  
171
 else
172
 monitor.setTextColor(colors.red)
173
end
174
 
175
monitor.write('Rotor Speed: '..turbine3.getRotorSpeed()..' rpm')
176
177
monitor.setCursorPos(40,15)
178
if turbine3.getEnergyProducedLastTick()>= 25000 then
179
 monitor.setTextColor(colors.green)
180
 else
181
 monitor.setTextColor(colors.red)
182
end
183
monitor.write('Generation: '..turbine3.getEnergyProducedLastTick()..' rf/t')
184
185
monitor.setCursorPos(40,17)
186
monitor.setTextColor(colors.white)
187
monitor.write('Capacitor Banks:')
188
189
monitor.setCursorPos(40,18)
190
if turbine1.getEnergyStored()>=9900000 then
191
 monitor.setTextColor(colors.red)
192
 else
193
 monitor.setTextColor(colors.green)
194
end
195
monitor.write('Turbine 1: '..turbine1.getEnergyStored()..' RF')
196
197
monitor.setCursorPos(40,19)
198
if turbine2.getEnergyStored()>=9900000 then
199
 monitor.setTextColor(colors.red)
200
 else
201
 monitor.setTextColor(colors.green)
202
end
203
monitor.write('Turbine 2: '..turbine2.getEnergyStored()..' RF')
204
205
monitor.setCursorPos(40,18)
206
if turbine3.getEnergyStored()>=9900000 then
207
 monitor.setTextColor(colors.red)
208
 else
209
 monitor.setTextColor(colors.green)
210
end
211
monitor.write('Turbine 3: '..turbine3.getEnergyStored()..' RF')
212
 
213
 
214
 
215
 monitor.setCursorPos(1,9)
216
 monitor.setTextColor(colors.white)
217
 monitor.write('Control Rod Levels:')
218
 monitor.setTextColor(colors.green)
219
 monitor.setCursorPos(1,10)
220
 monitor.write('Rods  1-24:  '..(100-(reactor.getControlRodLevel(0)))..'%')
221
 
222
 monitor.setCursorPos(20,10)
223
 monitor.write('Rods   24-48:  '..(100-(reactor.getControlRodLevel(1)))..'%')
224
 
225
 monitor.setCursorPos(1,11)
226
 monitor.write('Rods 72-96:  '..(100-(reactor.getControlRodLevel(2)))..'%')
227
 
228
 monitor.setCursorPos(20,11)
229
 monitor.write('Rods 120-144:  '..(100-(reactor.getControlRodLevel(3)))..'%')
230
 
231
 monitor.setCursorPos(1,14)
232
 monitor.setTextColor(colors.white)
233
 monitor.write('Reactor Radioactivity')
234
 
235
 monitor.setCursorPos(24,14)
236
 monitor.write('Fuel Usage')
237
 
238
 monitor.setTextColor(colors.green)
239
 monitor.setCursorPos(1,15)
240
 monitor.write(''..reactor.getFuelReactivity()..'%')
241
 monitor.setCursorPos(24,15)
242
 monitor.write(''..reactor.getFuelConsumedLastTick()..' mb/t')
243
 
244
 monitor.setCursorPos(1,16)
245
monitor.setTextColor(colors.orange)
246
monitor.write('Status:')
247
 
248
if flashflag==0 then
249
  flashflag=1
250
  if offlineflag==1 then
251
    monitor.setCursorPos(1,17)
252
    monitor.setTextColor(colors.lightGray)
253
    monitor.write('OFFLINE - Manual Override')
254
  end
255
  if emptyflag==1 then
256
    monitor.setCursorPos(1,17)
257
    monitor.setTextColor(colors.pink)
258
    monitor.write('OFFLINE - Fuel Exhausted')
259
  end
260
  if emptyflag==0 and offlineflag==0 and reactor.getControlRodLevel(0)>75 then
261
    monitor.setCursorPos(1,17)
262
    monitor.setTextColor(colors.yellow)
263
    monitor.write('ONLINE - Low Power Mode')
264
  end
265
  if emptyflag==0 and offlineflag==0 and reactor.getControlRodLevel(0)<=75 then
266
    monitor.setCursorPos(1,17)
267
    monitor.setTextColor(colors.orange)
268
    monitor.write('ONLINE - High Power Mode')
269
  end
270
else
271
  flashflag=0
272
  monitor.setCursorPos(1,17)
273
  monitor.clearLine()
274
end
275
276
277
278
279-
if reactor.getEnergyProducedLastTick<=5999 then
279+
if reactor.getEnergyProducedLastTick()<=5999 then
280
    reactor.setAllControlRodLevels(0+(math.floor(reactor.getEnergyProducedLastTick()/6000)))
281
282
elseif reactor.getEnergyProducedLastTick()>=6000 then
283
	reactor.setAllControlRodLevels(100)
284
else
285
	reactor.setAllControlRodLevels(0)
286
end
287
288
if (reactor.getFuelAmount()<=100) and offlineflag==0 then
289
    reactor.setAllControlRodLevels(100)
290
    reactor.setActive(false)
291
    emptyflag=1
292
else
293
    emptyflag=0
294
end
295
296
if rs.getInput('bottom')==false and emptyflag==0 then
297
    reactor.setActive(true)
298
    offlineflag=0
299
end
300
301
if rs.getInput('bottom')==true and emptyflag==0 then
302
    reactor.setActive(false)
303
    reactor.setAllControlRodLevels(100)
304
    offlineflag=1
305
end    
306-
sleep(1)
306+
307
end