Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.setBackgroundColor(colors.white)
- term.clear()
- local qlv = paintutils.loadImage("qlv")
- paintutils.drawImage(qlv, 2, 1)
- local h2 = fs.open("qlvd", "r")
- itinerari = textutils.unserialize(h2.readAll())
- h2.close()
- 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
- -- Variabili da popolare
- pedali = {}
- clicktopedale = {}
- while true do
- term.setBackgroundColor(colors.white)
- term.clear()
- local qlv = paintutils.loadImage("qlv")
- paintutils.drawImage(qlv, 2, 1)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.white)
- term.setCursorPos(15, 1)
- term.write("SELEZIONA PEDALI")
- local ev, b, x, y = os.pullEvent("mouse_click")
- if y > 17 then break end
- term.setBackgroundColor(colors.orange)
- term.setCursorPos(x, y)
- term.write(" ")
- term.setBackgroundColor(colors.white)
- term.setCursorPos(5, 3)
- term.write("Inserisci colore input")
- local color = read()
- table.insert(pedali, {x=x, y=y, color=color})
- clicktopedale[x.."_"..y] = #pedali
- end
- term.setBackgroundColor(colors.white)
- term.clear()
- local qlv = paintutils.loadImage("qlv")
- paintutils.drawImage(qlv, 2, 1)
- for k, v in ipairs(itinerari) do
- term.setBackgroundColor(colors.white)
- term.clear()
- local qlv = paintutils.loadImage("qlv")
- paintutils.drawImage(qlv, 2, 1)
- for k, v in ipairs(pedali) do
- term.setBackgroundColor(colors.orange)
- term.setCursorPos(v.x, v.y)
- term.write(" ")
- term.setBackgroundColor(colors.white)
- end
- drawFilledBox(1, 1, 50, 1, colors.white)
- term.setCursorPos(3, 1)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.white)
- term.write(v.name)
- local ev, bt, x, y = os.pullEvent("mouse_click")
- if clicktopedale[x.."_"..y] ~= nil then
- itinerari[k].pedale = clicktopedale[x.."_"..y]
- term.setBackgroundColor(colors.green)
- term.setCursorPos(x, y)
- term.write(" ")
- term.setBackgroundColor(colors.white)
- sleep(2)
- end
- end
- local h3 = fs.open("qlvpedali", "w")
- h3.write(textutils.serialize(pedali))
- h3.close()
- local h4 = fs.open("qlvd", "w")
- h4.write(textutils.serialize(itinerari))
- h4.close()
- print("\n\nDONEEEEE")
Advertisement
Add Comment
Please, Sign In to add comment