Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- FoxInvest Holding
- ----------------------
- -- Titanus Elios
- -- Gestione dell'ASCENSORE 01
- -----------------------
- rednet.open("back")
- 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.white)
- term.setCursorPos((maxw - #testo) / 2, 1)
- term.setTextColor(colors.black)
- 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.black)
- term.setTextColor(colors.white)
- end
- function alarm(color, text)
- term.setBackgroundColor(colors[color])
- term.setTextColor(colors.white)
- print(" "..text.." ")
- no()
- end
- function spia(x, y, color)
- term.setBackgroundColor(colors[color])
- term.setCursorPos(x, y)
- term.write(" ")
- no()
- end
- function getStatus()
- rednet.send(5701, "status")
- local rID, message = rednet.receive(5)
- return message
- end
- dev = 0
- isMovement = 0
- while true do
- if dev == 0 then
- no()
- term.clear()
- titolo("Gestione ascensore 1 FIH")
- status = getStatus()
- print("\nAscensore N° 01 - Deposito")
- print("Terminale Unico Gestione Ascensore")
- print("\nPiano: " .. status)
- print("\n\nBASSO:")
- print("Salita treni:")
- if status == 0 then
- bottom = "green"
- top = "red"
- todo = "VAI IN SU"
- td = "up"
- elseif status == 1 then
- bottom = "red"
- top = "green"
- todo = "VAI IN GIU'"
- td = "down"
- else
- bottom = "gray"
- top = "gray"
- todo = "ERROR!"
- end
- spia(15, 9, bottom)
- print("\n\nALTO:")
- print("Salita treni:")
- spia(15, 12, top)
- print("\n\nInfo generali:\nAscesore in movimento:")
- if isMovement == 0 then
- mov = "green"
- btCl = "blue"
- else
- mov = "orange"
- btCl = "gray"
- end
- spia(32, 15, mov)
- bottone("blue", todo, 20, 17)
- local event, key, x, y = os.pullEvent("mouse_click")
- if x > 20 and y == 17 then
- rednet.send(5701, td)
- isMovement = 1
- end
- end
- sleep(0.2)
- end
Add Comment
Please, Sign In to add comment