View difference between Paste ID: 9S9LvTFw and 3P9VEnqb
SHOW: | | - or go back to the newest paste.
1
local event = require "event"
2
local component = require "component"
3
local reactor = component.reactor
4-
local redstone = component.proxy(component.get("a66"))
4+
local redstone = component.proxy(component.get("0a9"))
5
local rside = 5
6-
local ventpull = component.proxy(component.get("150"))
6+
local ventpull = component.proxy(component.get("0f6"))
7
local pullside = 4
8-
local ventput = component.proxy(component.get("150"))
8+
local ventput = component.proxy(component.get("0f6"))
9
local putside = 5
10-
local menet4 = component.proxy(component.get("ff8"))
10+
local menet4 = component.proxy(component.get("9b3"))
11
local m4side = 5
12
--local menet2 = component.proxy(component.get("8ca"))
13
--local menet1 = component.proxy(component.get("079"))
14
local gpu = component.gpu
15
local w, h = gpu.getResolution()
16
local inv = component.inventory_controller
17
local invside = 2
18
local invs = inv.getInventorySize(invside)
19
local power = 0
20
local changing = false
21
local heating = false
22
local loading=false
23
local lzhs = {}
24
local li=1
25
local rshs = {}
26
local si=1
27
local rods4 = {}
28
local ri4=1
29
local rods2 = {}
30
local ri2=1
31
local rods1 = {}
32
local ri1=1
33
local mox="Rod"
34
local moxdmg=20000
35
local vents = {}
36
local vi=1
37
local ahvs = {}
38
local ahvi=1
39
local ahes = {}
40
local ai=1
41
local ohes = {}
42
local oi=1
43
local hes = {}
44
local hi=1
45
local tnrs={}
46
local ti=1
47
local nrs={}
48
local ni=1
49
local c1s = {}
50
local c1i=1
51
local c3s = {}
52
local c3i=1
53
local c6s = {}
54
local c6i=1
55
local warn=false
56
local args={...}
57
local eutarget=1000
58
local preveu=nil
59
if #args>0 then
60
  eutarget=tonumber(args[1])
61
end
62
63
local prevb=0x000000
64
function setGpuB(b)
65
  if b~=prevb then
66
    gpu.setBackground(b)
67
    prevb=b
68
  end
69
end
70
71
local prevf=0x000000
72
function setGpuF(f)
73
  if f~=prevf then
74
    gpu.setForeground(f)
75
    prevf=f
76
  end
77
end
78
79
function getElement(pos)
80
  local l=" "
81
  if inv.getStackInSlot(invside,pos) then
82
    l=inv.getStackInSlot(invside,pos)
83
  end
84
  return l
85
end
86
87
local redDmg={}
88
local blackDmg={}
89
90
function drawDmg()
91
  if redDmg and #redDmg>0 then
92
    setGpuB(0xFF0000)
93
    for k,t in pairs(redDmg) do
94
      gpu.set(t[2],t[1],string.rep(" ",t[3]))
95
    end
96
  end
97
  if blackDmg and #blackDmg>0 then
98
    setGpuB(0x1E1E1E)
99
    for k,t in pairs(blackDmg) do
100
      gpu.set(t[2],t[1],string.rep(" ",t[3]))
101
    end
102
  end
103
end
104
105
function fillDmg(i,j,el,dmg)
106
  if el=="LZH" then
107
    dmg=(100000-dmg)/10000
108
  elseif el=="Rod" or el=="RSH" then
109
    dmg=(20000-dmg)/2000
110
  elseif el=="Vent" or el=="AHV" then
111
    dmg=(1000-dmg)/100
112
  elseif el=="AHE" or el=="MOX" then
113
    dmg=(10000-dmg)/1000
114
  elseif el=="OHE" then
115
    dmg=(5000-dmg)/500
116
  elseif el=="HE" then
117
    dmg=(2500-dmg)/250
118
  elseif el=="TNR" then
119
    dmg=(120000-dmg)/12000
120
  elseif el=="NR" then
121
    dmg=(30000-dmg)/3000
122
  elseif el=="C1" then
123
    dmg=(10000-dmg)/1000
124
  elseif el=="C3" then
125
    dmg=(30000-dmg)/3000
126
  elseif el=="C6" then
127
    dmg=(60000-dmg)/6000
128
  end
129
  if dmg>0 then
130
    table.insert(redDmg,{i+5,j+2,dmg})
131
    if dmg<10 then
132
      table.insert(blackDmg,{i+5,j+2+dmg,11-dmg})
133
    end
134
  else
135
    table.insert(blackDmg,{i+5,j+2,10})
136
  end
137
--[[  setGpuB(0xFF0000)
138
  gpu.set(j+2,i+5,string.rep(" ",dmg))
139
  if dmg<10 then
140
    setGpuB(0x1E1E1E)
141
    gpu.set(j+2+dmg,i+5,string.rep(" ",10-dmg))
142
  end]]
143
end
144
145
function stopme()
146
  coroutine.yield()
147
  return 0
148
end
149
150
function checkDmg()
151
  redDmg={}
152
  blackDmg={}
153
  local dmg=0
154
  local needy=0
155
  local elem
156
  
157
  for i=1,li-1,1 do
158
    elem=inv.getStackInSlot(invside,lzhs[i][3])
159
    if elem then
160
      fillDmg(lzhs[i][1],lzhs[i][2],"LZH",elem.customDamage)
161
    else
162
      fillDmg(lzhs[i][1],lzhs[i][2],"LZH",100000)
163
    end
164
    needy=needy+1
165
    if needy>18 then
166
      needy=stopme()
167
    end
168
  end
169
170
  for i=1,si-1,1 do
171
    elem=inv.getStackInSlot(invside,rshs[i][3])
172
    if elem then
173
      fillDmg(rshs[i][1],rshs[i][2],"RSH",elem.customDamage)
174
    else
175
      fillDmg(rshs[i][1],rshs[i][2],"RSH",20000)
176
    end
177
    needy=needy+1
178
    if needy>18 then
179
      needy=stopme()
180
    end
181
  end
182
183
  for i=1,ri4-1,1 do
184
    elem=inv.getStackInSlot(invside,rods4[i][3])
185
    if string.match(elem.label,"MOX") then
186
      mox="MOX"
187
      moxdmg=10000
188
    else
189
      mox="Rod"
190
      moxdmg=20000
191
    end
192
    if elem and not string.match(elem.label,"Depleted") then
193
      fillDmg(rods4[i][1],rods4[i][2],mox,elem.customDamage)
194
    else
195
      fillDmg(rods4[i][1],rods4[i][2],mox,moxdmg)
196
    end
197
    needy=needy+1
198
    if needy>18 then
199
      needy=stopme()
200
    end
201
  end
202
  for i=1,ri2-1,1 do
203
    elem=inv.getStackInSlot(invside,rods2[i][3])
204
    if string.match(elem.label,"MOX") then
205
      mox="MOX"
206
      moxdmg=10000
207
    else
208
      mox="Rod"
209
      moxdmg=20000
210
    end
211
    if elem and not string.match(elem.label,"Depleted") then
212
      fillDmg(rods2[i][1],rods2[i][2],mox,elem.customDamage)
213
    else
214
      fillDmg(rods2[i][1],rods2[i][2],mox,moxdmg)
215
    end
216
    needy=needy+1
217
    if needy>18 then
218
      needy=stopme()
219
    end
220
  end
221
  for i=1,ri1-1,1 do
222
    elem=inv.getStackInSlot(invside,rods1[i][3])
223
    if string.match(elem.label,"MOX") then
224
      mox="MOX"
225
      moxdmg=10000
226
    else
227
      mox="Rod"
228
      moxdmg=20000
229
    end
230
    if elem and not string.match(elem.label,"Depleted") then
231
      fillDmg(rods1[i][1],rods1[i][2],mox,elem.customDamage)
232
    else
233
      fillDmg(rods1[i][1],rods1[i][2],mox,moxdmg)
234
    end
235
    needy=needy+1
236
    if needy>18 then
237
      needy=stopme()
238
    end
239
  end
240
241
  for i=1,vi-1,1 do
242
    elem=inv.getStackInSlot(invside,vents[i][3])
243
    if elem then
244
      fillDmg(vents[i][1],vents[i][2],"Vent",elem.customDamage)
245
    else
246
      fillDmg(vents[i][1],vents[i][2],"Vent",1000)
247
    end
248
    needy=needy+1
249
    if needy>18 then
250
      needy=stopme()
251
    end
252
  end
253
254
  for i=1,ahvi-1,1 do
255
    elem=inv.getStackInSlot(invside,ahvs[i][3])
256
    if elem then
257
      fillDmg(ahvs[i][1],ahvs[i][2],"AHV",elem.customDamage)
258
    else
259
      fillDmg(ahvs[i][1],ahvs[i][2],"AHV",1000)
260
    end
261
    needy=needy+1
262
    if needy>18 then
263
      needy=stopme()
264
    end
265
  end
266
267
  for i=1,ai-1,1 do
268
    elem=inv.getStackInSlot(invside,ahes[i][3])
269
    if elem then
270
      fillDmg(ahes[i][1],ahes[i][2],"AHE",elem.customDamage)
271
    else
272
      fillDmg(ahes[i][1],ahes[i][2],"AHE",10000)
273
    end
274
    needy=needy+1
275
    if needy>18 then
276
      needy=stopme()
277
    end
278
  end
279
280
  for i=1,oi-1,1 do
281
    elem=inv.getStackInSlot(invside,ohes[i][3])
282
    if elem then
283
      fillDmg(ohes[i][1],ohes[i][2],"OHE",elem.customDamage)
284
    else
285
      fillDmg(ohes[i][1],ohes[i][2],"OHE",5000)
286
    end
287
    needy=needy+1
288
    if needy>18 then
289
      needy=stopme()
290
    end
291
  end
292
293
  for i=1,hi-1,1 do
294
    elem=inv.getStackInSlot(invside,hes[i][3])
295
    if elem then
296
      fillDmg(hes[i][1],hes[i][2],"HE",elem.customDamage)
297
    else
298
      fillDmg(hes[i][1],hes[i][2],"HE",2500)
299
    end
300
    needy=needy+1
301
    if needy>18 then
302
      needy=stopme()
303
    end
304
  end
305
306
  for i=1,ti-1,1 do
307
    elem=inv.getStackInSlot(invside,tnrs[i][3])
308
    if elem then
309
      fillDmg(tnrs[i][1],tnrs[i][2],"TNR",elem.customDamage)
310
    else
311
      fillDmg(tnrs[i][1],tnrs[i][2],"TNR",120000)
312
    end
313
    needy=needy+1
314
    if needy>18 then
315
      needy=stopme()
316
    end
317
  end
318
319
  for i=1,ni-1,1 do
320
    elem=inv.getStackInSlot(invside,nrs[i][3])
321
    if elem then
322
      fillDmg(nrs[i][1],nrs[i][2],"NR",elem.customDamage)
323
    else
324
      fillDmg(nrs[i][1],nrs[i][2],"NR",30000)
325
    end
326
    needy=needy+1
327
    if needy>18 then
328
      needy=stopme()
329
    end
330
  end
331
332
  for i=1,c1i-1,1 do
333
    elem=inv.getStackInSlot(invside,c1s[i][3])
334
    if elem then
335
      fillDmg(c1s[i][1],c1s[i][2],"C1",elem.customDamage)
336
    else
337
      fillDmg(c1s[i][1],c1s[i][2],"C1",10000)
338
    end
339
    needy=needy+1
340
    if needy>18 then
341
      needy=stopme()
342
    end
343
  end
344
345
  for i=1,c3i-1,1 do
346
    elem=inv.getStackInSlot(invside,c3s[i][3])
347
    if elem then
348
      fillDmg(c3s[i][1],c3s[i][2],"C3",elem.customDamage)
349
    else
350
      fillDmg(c3s[i][1],c3s[i][2],"C3",30000)
351
    end
352
    needy=needy+1
353
    if needy>18 then
354
      needy=stopme()
355
    end
356
  end
357
358
  for i=1,c6i-1,1 do
359
    elem=inv.getStackInSlot(invside,c6s[i][3])
360
    if elem then
361
      fillDmg(c6s[i][1],c6s[i][2],"C6",elem.customDamage)
362
    else
363
      fillDmg(c6s[i][1],c6s[i][2],"C6",60000)
364
    end
365
    needy=needy+1
366
    if needy>18 then
367
      needy=stopme()
368
    end
369
  end
370
371
  drawDmg()
372
end
373
374
function fillElement(i,j,el,pos)
375
  local j1=9+j
376
  local i1=2+i
377
  pos=pos or 1
378
  local l=" "
379
  if el.label then
380
    l=el.label
381
  end
382
  if el=="X" then
383
    setGpuB(0x696969)
384
    setGpuF(0x3C3C3C)
385
    gpu.set(j1+1,i1,"\")
386
    gpu.set(j1+11,i1,"/")
387
    gpu.set(j1+3,i1+1,"\")
388
    gpu.set(j1+9,i1+1,"/")
389
    gpu.set(j1+5,i1+2,"\")
390
    gpu.set(j1+7,i1+2,"/")
391
    gpu.set(j1+7,i1+3,"\")
392
    gpu.set(j1+5,i1+3,"/")
393
    gpu.set(j1+9,i1+4,"\")
394
    gpu.set(j1+3,i1+4,"/")
395
    gpu.set(j1+11,i1+5,"\")
396
    gpu.set(j1+1,i1+5,"/")
397
  elseif el=="0" then
398
    gpu.set(j1+1,i1,"══════")
399
    gpu.set(j1+1,i1+5,"══════")
400
    gpu.set(j1,i1+1,"║║║║",true)
401
    gpu.set(j1+7,i1+1,"║║║║",true)
402
  elseif el=="1" then
403
    gpu.set(j1+7,i1+1,"║║║║",true)
404
  elseif el=="2" then
405
    gpu.set(j1+1,i1,"══════")
406
    gpu.set(j1+1,i1+2,"══════")
407
    gpu.set(j1+1,i1+5,"══════")
408
    gpu.set(j1,i1+3,"║║",true)
409
    gpu.set(j1+7,i1+1,"║")
410
  elseif el=="3" then
411
    gpu.set(j1+1,i1,"══════")
412
    gpu.set(j1+1,i1+2,"══════")
413
    gpu.set(j1+1,i1+5,"══════")
414
    gpu.set(j1+7,i1+3,"║║",true)
415
    gpu.set(j1+7,i1+1,"║")
416
  elseif el=="4" then
417
    gpu.set(j1+1,i1+2,"══════")
418
    gpu.set(j1,i1+1,"║")
419
    gpu.set(j1+7,i1+1,"║")
420
    gpu.set(j1+7,i1+3,"║║",true)
421
  elseif el=="5" then
422
    gpu.set(j1+1,i1,"══════")
423
    gpu.set(j1+1,i1+2,"══════")
424
    gpu.set(j1+1,i1+5,"══════")
425
    gpu.set(j1,i1+1,"║")
426
    gpu.set(j1+7,i1+3,"║║",true)
427
  elseif el=="6" then
428
    gpu.set(j1+1,i1,"══════")
429
    gpu.set(j1+1,i1+2,"══════")
430
    gpu.set(j1+1,i1+5,"══════")
431
    gpu.set(j1,i1+1,"║")
432
    gpu.set(j1,i1+3,"║║",true)
433
    gpu.set(j1+7,i1+3,"║║",true)
434
  elseif el=="7" then
435
    gpu.set(j1+1,i1,"══════")
436
    gpu.set(j1+7,i1+1,"║║║║",true)
437
  elseif el=="8" then
438
    gpu.set(j1+1,i1,"══════")
439
    gpu.set(j1+1,i1+2,"══════")
440
    gpu.set(j1+1,i1+5,"══════")
441
    gpu.set(j1,i1+1,"║")
442
    gpu.set(j1+7,i1+1,"║")
443
    gpu.set(j1,i1+3,"║║",true)
444
    gpu.set(j1+7,i1+3,"║║",true)
445
  elseif el=="9" then
446
    gpu.set(j1+1,i1,"══════")
447
    gpu.set(j1+1,i1+2,"══════")
448
    gpu.set(j1+1,i1+5,"══════")
449
    gpu.set(j1,i1+1,"║")
450
    gpu.set(j1+7,i1+3,"║║",true)
451
    gpu.set(j1+7,i1+1,"║")
452
  elseif string.match(l,"LZH") then
453
    setGpuB(0x0000C0)
454
    gpu.fill(j1+1,i1+1,12,4," ")
455
    lzhs[li]={i1,j1,pos}
456
    li=li+1
457
  elseif string.match(l,"RSH") then
458
    setGpuB(0xC00000)
459
    gpu.fill(j1+1,i1+1,12,4," ")
460
    rshs[si]={i1,j1,pos}
461
    si=si+1
462
  elseif string.match(l,"Quad") then
463
    if string.match(l,"MOX") then
464
      setGpuB(0x66B680)
465
    else
466
      setGpuB(0x006D00)
467
    end
468
    gpu.fill(j1+1,i1+1,2,4," ")
469
    gpu.fill(j1+4,i1+1,2,4," ")
470
    gpu.fill(j1+8,i1+1,2,4," ")
471
    gpu.fill(j1+11,i1+1,2,4," ")
472
    rods4[ri4]={i1,j1,pos}
473
    ri4=ri4+1
474
  elseif string.match(l,"Dual") then
475
    if string.match(l,"MOX") then
476
      setGpuB(0x66B680)
477
    else
478
      setGpuB(0x006D00)
479
    end
480
    gpu.fill(j1+4,i1+1,2,4," ")
481
    gpu.fill(j1+8,i1+1,2,4," ")
482
    rods2[ri2]={i1,j1,pos}
483
    ri2=ri2+1
484
  elseif string.match(l,"Rod") then
485
    if string.match(l,"MOX") then
486
      setGpuB(0x66B680)
487
    else
488
      setGpuB(0x006D00)
489
    end
490
    gpu.fill(j1+6,i1+1,2,4," ")
491
    rods1[ri1]={i1,j1,pos}
492
    ri1=ri1+1
493
  elseif string.match(l,"Advanced Heat Vent") then
494
    setGpuB(0x33B6FF)
495
    gpu.fill(j1+1,i1+1,12,4," ")
496
    ahvs[ahvi]={i1,j1,pos}
497
    ahvi=ahvi+1
498
  elseif string.match(l,"Overclocked") then
499
    setGpuB(0xFFFF40)
500
    gpu.fill(j1+1,i1+1,12,4," ")
501
    vents[vi]={i1,j1,pos}
502
    vi=vi+1
503
  elseif string.match(l,"Component Heat Vent") then
504
    setGpuB(0xE1E1E1)
505
    gpu.fill(j1+1,i1+1,12,4," ")
506
  elseif string.match(l,"Reactor Heat Vent") then
507
    setGpuB(0xFF6D00)
508
    gpu.fill(j1+1,i1+1,12,4," ")
509
    vents[vi]={i1,j1,pos}
510
    vi=vi+1
511
  elseif string.match(l,"Heat Vent") then
512
    setGpuB(0xA5A5A5)
513
    gpu.fill(j1+1,i1+1,12,4," ")
514
    vents[vi]={i1,j1,pos}
515
    vi=vi+1
516
  elseif string.match(l,"Advanced Heat Exchanger") then
517
    setGpuB(0xE1E1E1)
518
    gpu.fill(j1+1,i1+1,12,4," ")
519
    setGpuB(0x33B6FF)
520
    gpu.fill(j1+3,i1+2,8,2," ")
521
    ahes[ai]={i1,j1,pos}
522
    ai=ai+1
523
  elseif string.match(l,"Component Heat Exchanger") then
524
    setGpuB(0xE1E1E1)
525
    gpu.fill(j1+1,i1+1,12,4," ")
526
    setGpuB(0xFFFF40)
527
    gpu.fill(j1+3,i1+2,8,2," ")
528
    ohes[oi]={i1,j1,pos}
529
    oi=oi+1
530
  elseif string.match(l,"Reactor Heat Exchanger") then
531
    setGpuB(0xE1E1E1)
532
    gpu.fill(j1+1,i1+1,12,4," ")
533
    setGpuB(0xFF6D00)
534
    gpu.fill(j1+3,i1+2,8,2," ")
535
    ohes[oi]={i1,j1,pos}
536
    oi=oi+1
537
  elseif string.match(l,"Heat Exchanger") then
538
    setGpuB(0xE1E1E1)
539
    gpu.fill(j1+1,i1+1,12,4," ")
540
    setGpuB(0xA5A5A5)
541
    gpu.fill(j1+3,i1+2,8,2," ")
542
    hes[hi]={i1,j1,pos}
543
    hi=hi+1
544
  elseif string.match(l,"Iridium") then
545
    setGpuB(0xFFFFFF)
546
    gpu.fill(j1+1,i1+1,12,4," ")
547
  elseif string.match(l,"Thick") then
548
    setGpuB(0xFFFFFF)
549
    gpu.fill(j1+1,i1+1,12,4," ")
550
    tnrs[ti]={i1,j1,pos}
551
    ti=ti+1
552
  elseif string.match(l,"Neutron") then
553
    setGpuB(0xFFFFFF)
554
    gpu.fill(j1+1,i1+1,12,4," ")
555
    setGpuB(0xA5A5A5)
556
    gpu.fill(j1+4,i1+2,6,2," ")
557
    nrs[ni]={i1,j1,pos}
558
    ni=ni+1
559
  elseif string.match(l,"10k") then
560
    setGpuB(0x0000C0)
561
    gpu.fill(j1+6,i1+1,2,4," ")
562
    c1s[c1i]={i1,j1,pos}
563
    c1i=c1i+1
564
  elseif string.match(l,"30k") then
565
    setGpuB(0x0000C0)
566
    gpu.fill(j1+3,i1+1,2,4," ")
567
    gpu.fill(j1+6,i1+1,2,4," ")
568
    gpu.fill(j1+9,i1+1,2,4," ")
569
    c3s[c3i]={i1,j1,pos}
570
    c3i=c3i+1
571
  elseif string.match(l,"60k") then
572
    setGpuB(0x0000C0)
573
    gpu.set(j1+3,i1+1,"  ")
574
    gpu.set(j1+6,i1+1,"  ")
575
    gpu.set(j1+9,i1+1,"  ")
576
    gpu.set(j1+3,i1+3,"  ")
577
    gpu.set(j1+6,i1+3,"  ")
578
    gpu.set(j1+9,i1+3,"  ")
579
    c6s[c6i]={i1,j1,pos}
580
    c6i=c6i+1
581
  elseif string.match(l,"Containment") then
582
    setGpuB(0x996D40)
583
    gpu.fill(j1+1,i1+1,12,4," ")
584
  elseif string.match(l,"Capacity") then
585
    setGpuB(0xFF6D00)
586
    gpu.fill(j1+1,i1+1,12,4," ")
587
  elseif string.match(l,"Plating") then
588
    setGpuB(0xB4B4B4)
589
    gpu.fill(j1+1,i1+1,12,4," ")
590
  end
591
end
592
593
function drawReactor()
594
  setGpuB(0x696969)
595
  for i=2,37,7 do
596
    for j=9,137,16 do
597
      gpu.fill(j,i,14,6," ")
598
    end
599
  end
600
end
601
602
function drawElement(i,j)
603
  local i1=i/7
604
  local j1=j/16+1
605
  local pos=i1*9+j1
606
  local s=(invs-4)/6
607
  if s<9 then
608
    for g=8,s,-1 do
609
      local m=math.fmod(pos,g+1)
610
      if m==0 then
611
        fillElement(i,j,"X")
612
        return
613
      end
614
      local d=(pos-m)/(g+1)
615
      pos=pos-d
616
    end
617
  end
618
  local el=getElement(pos)
619
  fillElement(i,j,el,pos)
620
end
621
622
function fillEU(eu)
623
  if preveu==nil or eu~=preveu then
624
    setGpuB(0x000000)
625
    gpu.fill(88,44,72,6," ")
626
    setGpuF(0x00B6FF)
627
    local l = string.len(eu)
628
    for i=l,1,-1 do
629
      fillElement(42,140-(l-i)*10,string.sub(eu,i,i))
630
    end
631
    preveu=eu
632
  end
633
end
634
635
function fillPower(power)
636
  if power>0 then
637
    setGpuB(0x00FF00)
638
  else
639
    setGpuB(0xFF0000)
640
  end
641
  gpu.fill(2,45,14,5," ")
642
end
643
644
function fillWarning(w)
645
  setGpuB(w)
646
  gpu.fill(18,45,14,5," ")
647
end
648
649
local m4p=15
650
local m2p=15
651
local m1p=15
652
menet4.setOutput(m4side,15)
653
ventpull.setOutput(pullside,15)
654
ventput.setOutput(putside,15)
655
--menet2.setOutput(2,15)
656
--menet1.setOutput(1,15)
657
658
function rodsChanged()
659
  for i=1,ri4-1,1 do
660
    if not inv.getStackInSlot(invside,rods4[i][3]) or (inv.getStackInSlot(invside,rods4[i][3]) and string.match(inv.getStackInSlot(invside,rods4[i][3]).label,"Depleted")) then
661
      if m4p==15 then
662
        m4p=0
663
        m2p=15
664
        m1p=15
665
        menet4.setOutput(m4side,0)
666
        --menet2.setOutput(2,15)
667
        --menet1.setOutput(1,15)
668
      end
669
      return false
670
    end
671
  end
672
  for i=1,ri2-1,1 do
673
    if not inv.getStackInSlot(invside,rods2[i][3]) or (inv.getStackInSlot(invside,rods2[i][3]) and string.match(inv.getStackInSlot(invside,rods2[i][3]).label,"Depleted")) then
674
      if m2p==15 then
675
        m4p=15
676
        m2p=0
677
        m1p=15
678
        menet4.setOutput(m4side,15)
679
        --menet2.setOutput(2,0)
680
        --menet1.setOutput(1,15)
681
      end
682
      return false
683
    end
684
  end
685
  for i=1,ri1-1,1 do
686
    if not inv.getStackInSlot(invside,rods1[i][3]) or (inv.getStackInSlot(invside,rods1[i][3]) and string.match(inv.getStackInSlot(invside,rods1[i][3]).label,"Depleted")) then
687
      if m1p==15 then
688
        m4p=15
689
        m2p=15
690
        m1p=0
691
        menet4.setOutput(m4side,15)
692
        --menet2.setOutput(2,15)
693
        --menet1.setOutput(1,0)
694
      end
695
      return false
696
    end
697
  end
698
  menet4.setOutput(m4side,15)
699
  return true
700
end
701
702
function ventLoaded()
703
  for i=1,ahvi-1,1 do
704
    if not inv.getStackInSlot(invside,ahvs[i][3]) then
705
      return false
706
    end
707
  end
708
  return true
709
end
710
711
function continueWork()
712
  if warn then
713
    return true
714
  end
715
  if heating and reactor.getHeat()>8800 then
716
    redstone.setOutput(rside,0)
717
    ventpull.setOutput(pullside,15)
718
    ventput.setOutput(putside,0)
719
    fillWarning(0xAED6F1)
720
    heating=false
721
    loading=true
722
  else
723
    if reactor.getHeat()>9900 then
724
      power=0
725
      redstone.setOutput(rside,power)
726
      menet4.setOutput(m4side,15)
727
      ventpull.setOutput(pullside,15)
728
      ventput.setOutput(putside,15)
729
      --menet2.setOutput(2,15)
730
      --menet1.setOutput(1,15)
731
      fillPower(power)
732
      fillWarning(0xFFB600)
733
      fillEU(0)
734
      warn=true
735
      return true
736
    end
737
  end
738
  local eu = math.floor(reactor.getReactorEUOutput())
739
  if changing then
740
    if not rodsChanged() then
741
      return true --do nothing
742
    else
743
      changing=false
744
      power=15
745
      redstone.setOutput(rside,power)
746
      fillWarning(0x000000)
747
    end
748
  else
749
    if loading then
750
      if not ventLoaded() then
751
        return true
752
      else
753
        ventput.setOutput(putside,15)
754
        redstone.setOutput(rside,15)
755
        fillWarning(0x000000)
756
        loading=false
757
      end
758
    else
759
      if reactor.getHeat()<8800 then
760
        ventpull.setOutput(pullside,0)
761
        fillWarning(0xFCF3CF)
762
        heating=true
763
      else
764
        if eu<eutarget and power>0 then
765
          changing=true
766
          power=0
767
          redstone.setOutput(rside,power)
768
          fillWarning(0x006D00)
769
          fillEU(0)
770
          return true
771
        end
772
      end
773
    end
774
  end
775
  fillEU(eu)
776
  --checkDmg()
777
  return true
778
end
779
780
function shutexit()
781
  redstone.setOutput(rside,0)
782
  setGpuF(0xFFFFFF)
783
  setGpuB(0x000000)
784
  gpu.fill(1, 1, w, h, " ")
785
  return false
786
end
787
788
local myEventHandlers = setmetatable({}, { __index = function() return continueWork end })
789
790
function myEventHandlers.key_down(adress, char, code, playerName)
791
  if code==57 then
792
    if not changing then
793
      if power==0 then
794
        if warn then
795
          warn=false
796
          fillWarning(0x000000)
797
        end
798
        power=15
799
      else
800
        power=0
801
      end
802
      fillPower(power)
803
      redstone.setOutput(rside,power)
804
    end
805
  elseif code==46 then
806
    return shutexit()
807
  end
808
  return true
809
end
810
811
function myEventHandlers.interrupted(...)
812
  return shutexit()
813
end
814
815
function handleEvent(eventID, ...)
816
  if (eventID) then
817
    return myEventHandlers[eventID](...)
818
  end
819
  return continueWork()
820
end
821
822
setGpuB(0xC3C3C3)
823
824
gpu.fill(1, 1, w, h-7, " ")
825
826
drawReactor()
827
for i=0,35,7 do
828
  for j=0,128,16 do
829
    drawElement(i,j)
830
  end
831
end
832
833
if reactor.getReactorEUOutput()>0 then
834
  power=15
835
end
836
fillPower(power)
837
838
td=coroutine.create(function()
839
  while true do
840
    checkDmg()
841
    os.sleep(0)
842
  end
843
end)
844
845
while handleEvent(event.pull(1)) do
846
  coroutine.resume(td)
847
end