Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function clear()
- term.clear()
- term.setCursorPos(1, 1)
- end
- -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX
- 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 testo(sfumatura) term.setTextColour(sfumatura) end
- function sfondo(sfumaturaSfondo) term.setBackgroundColour(sfumaturaSfondo) end
- function disegnaDeviatoio(x, y, colore, lato)
- if colors.test(rs.getBundledInput("bottom"), colore) then
- term.setCursorPos(x, y)
- if lato == "dx" then
- term.write("/")
- else
- term.write("\\")
- end
- else
- term.setCursorPos(x, y)
- term.write("-")
- end
- end
- function disegnaSegnale(x, y, colore)
- if colors.test(rs.getBundledInput("bottom"), colore) then
- paintutils.drawPixel(x, y, colors.lime)
- else
- paintutils.drawPixel(x, y, colors.red)
- end
- end
- function disegnaSegnaleDoppio(x, y, colore1, colore2)
- if colors.test(rs.getBundledInput("bottom"), colore1) then
- paintutils.drawPixel(x, y, colors.red)
- paintutils.drawPixel(x, y+1, colors.lime)
- else
- paintutils.drawPixel(x, y, colors.lime)
- paintutils.drawPixel(x, y+1, colors.black)
- end
- end
- function disegnaQLV()
- sfondo(colors.white)
- testo(colors.black)
- clear()
- term.setCursorPos(1, 1)
- qlv = paintutils.loadImage("qlv")
- paintutils.drawImage(qlv, 1, 1)
- -- Segnali
- sfondo(colors.white)
- testo(colors.black)
- term.setCursorPos(5, 10)
- term.write("|")
- disegnaSegnale(5, 9, colors.white)
- sfondo(colors.white)
- testo(colors.black)
- term.setCursorPos(48, 10)
- term.write("|")
- disegnaSegnale(48, 9, colors.orange)
- sfondo(colors.white)
- testo(colors.black)
- -- numeri binari
- testo(colors.green)
- term.setCursorPos(24, 10)
- term.write("II")
- term.setCursorPos(25, 12)
- term.write("I")
- -- origini itinerari
- testo(colors.red)
- term.setCursorPos(2, 12)
- term.write("1")
- term.setCursorPos(47, 12)
- term.write("2")
- --FV e destinazioni
- testo(colors.black)
- term.setCursorPos(2, 15)
- term.write("Thwolle F V PM Grottalupara")
- --Pulsanti
- sfondo(colours.red)
- testo(colors.white)
- term.setCursorPos(2, 2)
- -- 2 -> 11, 2
- term.write(" TLBCA 1 ")
- term.setCursorPos(12, 2)
- -- 12 -> 21, 2
- term.write(" TLBCA 2 ")
- -- 22 -> 31, 2
- sfondo(colors.cyan)
- term.setCursorPos(2, 4)
- -- 2 -> 7, 4
- term.setCursorPos(2, 4)
- term.write(" 1-I ")
- -- 7 -> 13, 4
- term.setCursorPos(8, 4)
- term.write(" 1-II ")
- -- 15 -> 20, 4
- term.setCursorPos(15, 4)
- term.write(" 2-I ")
- -- 21 -> 28, 4
- term.setCursorPos(21, 4)
- term.write(" 2-II ")
- --Deviatoi
- --01
- sfondo(colors.gray)
- testo(colors.white)
- disegnaDeviatoio(7, 11, colors.magenta, "sx")
- --02
- disegnaDeviatoio(41, 11, colors.lime, "dx")
- end
- function disegnaConferma(domanda)
- drawFilledBox(14, 8, 37, 14, colors.lightBlue)
- term.setCursorPos(15, 9)
- term.write("Eseguire il comando?")
- term.setCursorPos(15, 10)
- term.write(domanda)
- testo(colors.black)
- sfondo(colors.red)
- term.setCursorPos(16, 13)
- term.write(" No ")
- testo(colors.black)
- sfondo(colors.lime)
- term.setCursorPos(28, 13)
- term.write(" Si ")
- testo(colors.black)
- sfondo(colors.white)
- local scelta = false
- while scelta == false do
- event, key, x, y = os.pullEvent("mouse_click")
- if event == "mouse_click" and x > 16 and x < 24 and y == 13 then
- scelta = true
- return false
- elseif event == "mouse_click" and x > 28 and x < 36 and y == 13 then
- scelta = true
- return true
- end
- end
- end
- while true do
- disegnaQLV()
- event, par1, x, y = os.pullEvent()
- if event == "mouse_click" then
- if x < 11 and x > 2 and y == 2 and disegnaConferma("TLBCA 1") then
- rs.setBundledOutput("bottom", colors.pink)
- rs.setOutput("top", true)
- sleep(0.5)
- rs.setOutput("top", false)
- rs.setBundledOutput("bottom", 0)
- end
- if x < 21 and x > 12 and y == 2 and disegnaConferma("TLBCA 2") then
- rs.setBundledOutput("bottom", colors.lightGray)
- rs.setOutput("top", true)
- sleep(0.5)
- rs.setOutput("top", false)
- rs.setBundledOutput("bottom", 0)
- end
- if x < 7 and x > 2 and y == 4 then
- rs.setBundledOutput("bottom", colors.magenta)
- rs.setOutput("top", true)
- sleep(0.5)
- rs.setOutput("top", false)
- rs.setBundledOutput("bottom", 0)
- end
- if x < 13 and x > 8 and y == 4 then
- rs.setBundledOutput("bottom", colors.lightBlue)
- rs.setOutput("top", true)
- sleep(0.5)
- rs.setOutput("top", false)
- rs.setBundledOutput("bottom", 0)
- end
- if x < 20 and x > 15 and y == 4 then
- rs.setBundledOutput("bottom", colors.lime)
- rs.setOutput("top", true)
- sleep(0.5)
- rs.setOutput("top", false)
- rs.setBundledOutput("bottom", 0)
- end
- if x < 28 and x > 21 and y == 4 then
- rs.setBundledOutput("bottom", colors.yellow)
- rs.setOutput("top", true)
- sleep(0.5)
- rs.setOutput("top", false)
- rs.setBundledOutput("bottom", 0)
- end
- end
- end
Add Comment
Please, Sign In to add comment