View difference between Paste ID: 7A8Y9MXi and 3EPVkSLa
SHOW: | | - or go back to the newest paste.
1-
rednet.open("top")
1+
rednet.open("back")
2
3
-- FoxInvest Holding
4
----------------------
5
-- Titanus Elios
6
-- Gestione della Corrente
7
-----------------------
8
9
10
maxw, maxh = term.getSize()
11
local function drawPixelInternal(xPos, yPos)
12
    term.setCursorPos(xPos, yPos)
13
    term.write(" ")
14
end
15
 
16
local tColourLookup = {}
17
for n = 1, 16 do
18
    tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
19
end
20
 
21
function drawFilledBox(startX, startY, endX, endY, nColour)
22
    if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
23
        "number" or type(endY) ~= "number" or
24
        (nColour ~= nil and type(nColour) ~= "number") then
25
        error("Expected startX, startY, endX, endY, colour", 2)
26
    end
27
 
28
    startX = math.floor(startX)
29
    startY = math.floor(startY)
30
    endX = math.floor(endX)
31
    endY = math.floor(endY)
32
 
33
    if nColour then term.setBackgroundColor(nColour) end
34
    if startX == endX and startY == endY then
35
        drawPixelInternal(startX, startY)
36
        return
37
    end
38
 
39
    local minX = math.min(startX, endX)
40
    if minX == startX then
41
        minY = startY
42
        maxX = endX
43
        maxY = endY
44
    else
45
        minY = endY
46
        maxX = startX
47
        maxY = startY
48
    end
49
 
50
    for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
51
end
52
 
53
function clear()
54
    sfondo(colors.black)
55
    term.clear()
56
    term.setCursorPos(1, 1)
57
end
58
 
59
function clearRed()
60
    sfondo(colors.red)
61
    term.clear()
62
    term.setCursorPos(1, 1)
63
end
64
 
65
function titolo(testo)
66
    drawFilledBox(1, 1, maxw, 1, colors.blue)
67
    term.setCursorPos((maxw - #testo) / 2, 1)
68
    term.setTextColor(colors.white)
69
    term.write(testo)
70
end
71
72
function alarm(testo, colore, y)
73
    drawFilledBox(1, y, maxw, y, colors[colore])
74
    term.setCursorPos((maxw - #testo) / 2, y)
75
    term.setTextColor(colors.white)
76
    term.write(testo)
77
    no()
78
end
79
80
 
81
function bottone(color, text, x, y)
82
   term.setBackgroundColor(colors[color])
83
   term.setTextColor(colors.white)
84
   term.setCursorPos(x, y)
85
   print(text)
86
end
87
 
88
function no()
89
   term.setBackgroundColor(colors.white)
90
   term.setTextColor(colors.black)
91
end
92
93
don = 0
94
95
while true do
96
if don == 0 then
97
 rednet.send(4963, "status")
98
 id, msg1, ks = rednet.receive(5)
99
 if msg1 == "ON" then
100
   text1 = "-"
101
   colore1 = "green"
102
   do1 = "OFF"
103
 else
104
   text1 = "|"
105
   colore1 = "orange"
106
   do1 = "ON"
107
 end
108
 
109
 rednet.send(4961, "status")
110
 id, msg2, ls = rednet.receive(5)
111
 
112
 rednet.send(4962, "status")
113
 id, msg3, ls = rednet.receive(5)
114
 
115
 rednet.send(4964, "status")
116
 id, msg4, ls = rednet.receive(5)
117
 
118
 rednet.send(4967, "status")
119
 id, msg5, ls = rednet.receive(5)
120
 
121
 if msg2 == "ON" and msg3 == "OFF" then
122
   tensione = "HV"
123
   kw = "3000kW"
124
 elseif msg2 == "ON" and msg3 == "ON" and msg4 == "HV" then
125
   tensione = "HV"
126
   kw = "3512kW"
127
 elseif msg2 == "OFF" and msg3 == "ON" and msg4 == "MV" then
128
   tensione = "MV"
129
   kw = "128kW"
130
 elseif msg2 == "OFF" and msg3 == "ON" and msg4 == "HV" then
131
   tensione = "HV"
132
   kw = "512kW"
133
 else
134
   tensione = "N/D"
135
   kw = "0kW"
136
 end
137
 
138
 if msg5 == true then
139
   ups1 = "green"
140
 else
141
   ups1 = "lightGray"
142
 end
143
 
144
 if msg2 == "ON" then
145
   ups2 = "green"
146
 else
147
   ups2 = "lightGray"
148
 end
149
 
150
 if msg3 == "ON" and msg4 == "HV" then
151
   ups3 = "green"
152
 elseif msg3 == "ON" and msg4 == "MV" and msg2 == "OFF" then
153
   ups3 = "orange"
154
 elseif msg3 == "ON" and msg4 == "MV" and msg2 == "ON" then
155
   ups3 = "red"
156
 elseif msg2 == "ON" and msg3 == "OFF" then
157
   ups3 = "lime"
158
 else
159
   ups3 = "lightGray"
160
 end 
161
 term.setBackgroundColor(colors.white)
162
 term.clear()
163
 titolo("Gestione Mass - Titanus Elios")
164
 term.setTextColor(colors.black)
165
 term.setBackgroundColor(colors.white)
166
 print("\nBenvenuto nel pannello di gestione del Mass Fabricator")
167
 print("\nTensione: "..tensione.."\nkW dedicati al Mass:" ..kw)
168
 local image = paintutils.loadImage("mass")
169
 paintutils.drawImage(image, 5, 7)
170
 term.setCursorPos(17, 13)
171
 term.setBackgroundColor(colors.lightBlue)
172
 term.setTextColor(colors[colore1])
173
 print(text1)
174
 term.setBackgroundColor(colors.white)
175
 term.setTextColor(colors.black)
176
 term.setCursorPos(6, 13)
177
 print(kw.." ->")
178
 term.setCursorPos(40, 7)
179
 print("Amplifier")
180
 term.setBackgroundColor(colors[ups1])
181
 term.setCursorPos(43, 8)
182
 print("   ")
183
 no()
184
 term.setCursorPos(40, 9)
185
 print("Pres. Max")
186
 term.setBackgroundColor(colors[ups2])
187
 term.setCursorPos(43, 10)
188
 print("   ")
189
 no()
190
 term.setCursorPos(40, 11)
191
 print("Energia I")
192
 term.setBackgroundColor(colors[ups3])
193
 term.setCursorPos(43, 12)
194
 print("   ")
195
 no()
196
 bottone("red", "FERMA TUTTO", 2, 7)
197
 if msg2 == "ON" and msg3 == "ON" and msg4 == "MV" then
198
   alarm("!!! Le tensioni dai 2 input non corrispondono!", "orange", 17)
199
   alarm("!!! Corrente staccata dal centro Titanus Elios", "red", 18)
200
   rednet.send(4961, "OFF")
201
   rednet.send(4962, "OFF")
202
 end
203
end
204
local event, bt, x, y = os.pullEvent("mouse_click")
205
if y == 13 and x == 17 and don == 0 then
206
  rednet.send(4963, do1)
207
elseif y == 7 and x >= 2 and x <= 13 then
208
  rednet.send(4961, "OFF")
209
  rednet.send(4962, "OFF")
210
end
211
sleep(0.1)
212
end