Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("back")
- -- FoxInvest Holding
- ----------------------
- -- Titanus Elios
- -- Gestione della Corrente
- -----------------------
- maxw, maxh = term.getSize()
- local function drawPixelInternal(xPos, yPos)
- term.setCursorPos(xPos, yPos)
- term.write(" ")
- end
- local tColourLookup = {}
- for n = 1, 16 do
- tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
- end
- function drawFilledBox(startX, startY, endX, endY, nColour)
- if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
- "number" or type(endY) ~= "number" or
- (nColour ~= nil and type(nColour) ~= "number") then
- error("Expected startX, startY, endX, endY, colour", 2)
- end
- startX = math.floor(startX)
- startY = math.floor(startY)
- endX = math.floor(endX)
- endY = math.floor(endY)
- if nColour then term.setBackgroundColor(nColour) end
- if startX == endX and startY == endY then
- drawPixelInternal(startX, startY)
- return
- end
- local minX = math.min(startX, endX)
- if minX == startX then
- minY = startY
- maxX = endX
- maxY = endY
- else
- minY = endY
- maxX = startX
- maxY = startY
- end
- for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
- end
- function clear()
- sfondo(colors.black)
- term.clear()
- term.setCursorPos(1, 1)
- end
- function clearRed()
- sfondo(colors.red)
- term.clear()
- term.setCursorPos(1, 1)
- end
- function titolo(testo)
- drawFilledBox(1, 1, maxw, 1, colors.blue)
- term.setCursorPos((maxw - #testo) / 2, 1)
- term.setTextColor(colors.white)
- term.write(testo)
- end
- function alarm(testo, colore, y)
- drawFilledBox(1, y, maxw, y, colors[colore])
- term.setCursorPos((maxw - #testo) / 2, y)
- term.setTextColor(colors.white)
- term.write(testo)
- no()
- end
- function bottone(color, text, x, y)
- term.setBackgroundColor(colors[color])
- term.setTextColor(colors.white)
- term.setCursorPos(x, y)
- print(text)
- end
- function no()
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- end
- don = 0
- while true do
- if don == 0 then
- rednet.send(4963, "status")
- id, msg1, ks = rednet.receive(5)
- if msg1 == "ON" then
- text1 = "-"
- colore1 = "green"
- do1 = "OFF"
- else
- text1 = "|"
- colore1 = "orange"
- do1 = "ON"
- end
- rednet.send(4961, "status")
- id, msg2, ls = rednet.receive(5)
- rednet.send(4962, "status")
- id, msg3, ls = rednet.receive(5)
- rednet.send(4964, "status")
- id, msg4, ls = rednet.receive(5)
- rednet.send(4967, "status")
- id, msg5, ls = rednet.receive(5)
- if msg2 == "ON" and msg3 == "OFF" then
- tensione = "HV"
- kw = "3000kW"
- elseif msg2 == "ON" and msg3 == "ON" and msg4 == "HV" then
- tensione = "HV"
- kw = "3512kW"
- elseif msg2 == "OFF" and msg3 == "ON" and msg4 == "MV" then
- tensione = "MV"
- kw = "128kW"
- elseif msg2 == "OFF" and msg3 == "ON" and msg4 == "HV" then
- tensione = "HV"
- kw = "512kW"
- else
- tensione = "N/D"
- kw = "0kW"
- end
- if msg5 == true then
- ups1 = "green"
- else
- ups1 = "lightGray"
- end
- if msg2 == "ON" then
- ups2 = "green"
- else
- ups2 = "lightGray"
- end
- if msg3 == "ON" and msg4 == "HV" then
- ups3 = "green"
- elseif msg3 == "ON" and msg4 == "MV" and msg2 == "OFF" then
- ups3 = "orange"
- elseif msg3 == "ON" and msg4 == "MV" and msg2 == "ON" then
- ups3 = "red"
- elseif msg2 == "ON" and msg3 == "OFF" then
- ups3 = "lime"
- else
- ups3 = "lightGray"
- end
- term.setBackgroundColor(colors.white)
- term.clear()
- titolo("Gestione Mass - Titanus Elios")
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.white)
- print("\nBenvenuto nel pannello di gestione del Mass Fabricator")
- print("\nTensione: "..tensione.."\nkW dedicati al Mass:" ..kw)
- local image = paintutils.loadImage("mass")
- paintutils.drawImage(image, 5, 7)
- term.setCursorPos(17, 13)
- term.setBackgroundColor(colors.lightBlue)
- term.setTextColor(colors[colore1])
- print(text1)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.setCursorPos(6, 13)
- print(kw.." ->")
- term.setCursorPos(40, 7)
- print("Amplifier")
- term.setBackgroundColor(colors[ups1])
- term.setCursorPos(43, 8)
- print(" ")
- no()
- term.setCursorPos(40, 9)
- print("Pres. Max")
- term.setBackgroundColor(colors[ups2])
- term.setCursorPos(43, 10)
- print(" ")
- no()
- term.setCursorPos(40, 11)
- print("Energia I")
- term.setBackgroundColor(colors[ups3])
- term.setCursorPos(43, 12)
- print(" ")
- no()
- bottone("red", "FERMA TUTTO", 2, 7)
- if msg2 == "ON" and msg3 == "ON" and msg4 == "MV" then
- alarm("!!! Le tensioni dai 2 input non corrispondono!", "orange", 17)
- alarm("!!! Corrente staccata dal centro Titanus Elios", "red", 18)
- rednet.send(4961, "OFF")
- rednet.send(4962, "OFF")
- end
- end
- local event, bt, x, y = os.pullEvent("mouse_click")
- if y == 13 and x == 17 and don == 0 then
- rednet.send(4963, do1)
- elseif y == 7 and x >= 2 and x <= 13 then
- rednet.send(4961, "OFF")
- rednet.send(4962, "OFF")
- end
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement