View difference between Paste ID: UuhfKyGp and tYAHtUCg
SHOW: | | - or go back to the newest paste.
1
modemC = peripheral.wrap('back') --cable
2
modemW = peripheral.wrap('bottom')--wifi
3
chan = 51
4
reponse = nil
5
 
6
rednet.open('bottom')
7
rednet.open('back')
8
modemW.open(5)
9
10
11
EUn1 = 0
12
EUn2 = 0
13
RFn1 = 0
14
RFn2 = 0
15
EU2n1 = 0
16
EU2n2 = 0
17
RF2n1 = 0
18
RF2n2 = 0
19
moni = peripheral.wrap("monitor_2")
20
moni.setBackgroundColor(colors.black)
21
moni.setTextScale(1)
22
mfe = peripheral.wrap("right")
23
mfe2 = peripheral.wrap("ic2:mfsu_0")
24
mfeMax = mfe.getEUCapacity()
25
mfe2Max = mfe2.getEUCapacity()
26
cube2 = peripheral.wrap("left")
27
cube = peripheral.wrap("Advanced Energy Cube_1")
28
cubeMax = cube.getMaxEnergy()
29
cube2Max = cube2.getMaxEnergy()
30
31
32
function quelColor(energy)
33
if energy < 20 then c = colors.red end
34
if energy >20 and energy < 70 then c = colors.yellow end
35
if energy > 70 then c = colors.green  end
36
return(c)
37
end
38
39
function titre (x,y,titre,c)
40
moni.setTextColor(c)
41
moni.setCursorPos(x,y)
42
moni.write (titre)
43
end
44
45
function etat (x,y,n1,n2)
46
e = (n1 - n2)/100
47
e = math.floor (e)/10
48
if e < 0 then c = colors.red
49
else c = colors.green end
50
moni.setTextColor(c)
51
moni.setCursorPos(x,y)
52
moni.write (e)
53
moni.write ('K')
54
end
55
56
function barre (x,y,ener,col)
57
moni.setCursorPos(x,y)
58
I = ener /8
59
for i =1,I do
60
moni.setBackgroundColor(col)
61
moni.write(" ")
62
end
63
moni.setBackgroundColor(colors.black)
64
end
65
66
 
67
while true do
68
EU = math.floor(((mfe.getEUStored() ) / mfeMax ) *1000)/10
69
EU2 = math.floor(((mfe2.getEUStored() ) / mfe2Max ) *1000)/10
70
RF = math.floor((cube.getEnergy() / cubeMax ) *1000)/10
71
RF2 = math.floor((cube2.getEnergy() / cube2Max ) *1000)/10
72
EUn1 = mfe.getEUStored()
73
EU2n1 = mfe2.getEUStored()
74
RFn1 = cube.getEnergy()
75
RF2n1 = cube2.getEnergy()
76
77
moni.clear()
78
79
titre(10,1,"The Sentry",colors.yellow)
80
81
titre(2,3,"RF Principal",colors.white)
82
83
titre(2,8,"RF Secondaire",colors.white)
84
85
titre(16,3,"EU Principal",colors.white)
86
87
titre (16,8,"EU Secondaire",colors.white)
88
89
 
90
91
if EU2 < 90 then fan = 1
92
else fan = 0 end
93
modemW.transmit (5,fan,fan)
94
95
titre(20,4,EU,quelColor(EU))
96
moni.write("%")
97
barre(16,5,EU,quelColor(EU))
98
etat(19,6,EUn1,EUn2)
99
100
titre(20,9,EU2,quelColor(EU2))
101
moni.write("%")
102
barre(16,10,EU2,quelColor(EU2))
103
etat(19,11,EU2n1,EU2n2)
104
105
106
titre(6,4,RF,quelColor(RF))
107
moni.write("%")
108
barre(2,5,RF,quelColor(RF))
109
etat(5,6,RFn1,RFn2)
110
111
112
titre(6,9,RF2,quelColor(RF2))
113
moni.write("%")
114
barre(2,10,RF2,quelColor(RF2))
115
etat(5,11,RF2n1,RF2n2)
116
117
moni.setBackgroundColor(colors.black)
118
modemW.transmit(chan,56,cubeMax)
119
sleep(1)
120
modemW.transmit(chan,52,RFn1)
121
sleep(1)modemW.transmit(chan,57,cube2Max)
122
sleep(1)
123
modemW.transmit(chan,53,RF2n1)
124
sleep(1)modemW.transmit(chan,58,mfeMax)
125
sleep(1)
126
modemW.transmit(chan,54,EUn1)
127
sleep(1)modemW.transmit(chan,59,mfeMax)
128
sleep(1)
129
modemW.transmit(chan,55,EU2n1)
130
sleep(1)
131
132
EUn2 = EUn1
133
EU2n2 = EU2n1
134
RFn2 = RFn1
135
RF2n2 = RF2n1
136
137
sleep(15)
138
end