FoxWorn3365

mkpedali

Nov 16th, 2025 (edited)
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.23 KB | None | 0 0
  1. term.setBackgroundColor(colors.white)
  2. term.clear()
  3.  
  4. local qlv = paintutils.loadImage("qlv")
  5. paintutils.drawImage(qlv, 2, 1)
  6.  
  7. local h2 = fs.open("qlvd", "r")
  8. itinerari = textutils.unserialize(h2.readAll())
  9. h2.close()
  10.  
  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. -- Variabili da popolare
  54. pedali = {}
  55. clicktopedale = {}
  56.  
  57. while true do
  58.     term.setBackgroundColor(colors.white)
  59.     term.clear()
  60.  
  61.     local qlv = paintutils.loadImage("qlv")
  62.     paintutils.drawImage(qlv, 2, 1)
  63.  
  64.     term.setTextColor(colors.black)
  65.     term.setBackgroundColor(colors.white)
  66.     term.setCursorPos(15, 1)
  67.     term.write("SELEZIONA PEDALI")
  68.    
  69.     local ev, b, x, y = os.pullEvent("mouse_click")
  70.  
  71.     if y > 17 then break end
  72.    
  73.     term.setBackgroundColor(colors.orange)
  74.     term.setCursorPos(x, y)
  75.     term.write(" ")
  76.     term.setBackgroundColor(colors.white)
  77.  
  78.     term.setCursorPos(5, 3)
  79.     term.write("Inserisci colore input")
  80.     local color = read()
  81.  
  82.     table.insert(pedali, {x=x, y=y, color=color})  
  83.     clicktopedale[x.."_"..y] = #pedali
  84. end
  85.  
  86. term.setBackgroundColor(colors.white)
  87. term.clear()
  88.  
  89. local qlv = paintutils.loadImage("qlv")
  90. paintutils.drawImage(qlv, 2, 1)
  91.  
  92. for k, v in ipairs(itinerari) do
  93.     term.setBackgroundColor(colors.white)
  94.     term.clear()
  95.  
  96.     local qlv = paintutils.loadImage("qlv")
  97.     paintutils.drawImage(qlv, 2, 1)
  98.  
  99.     for k, v in ipairs(pedali) do
  100.         term.setBackgroundColor(colors.orange)
  101.         term.setCursorPos(v.x, v.y)
  102.         term.write(" ")
  103.         term.setBackgroundColor(colors.white)
  104.     end
  105.  
  106.     drawFilledBox(1, 1, 50, 1, colors.white)
  107.     term.setCursorPos(3, 1)
  108.     term.setTextColor(colors.black)
  109.     term.setBackgroundColor(colors.white)
  110.     term.write(v.name)
  111.  
  112.     local ev, bt, x, y = os.pullEvent("mouse_click")
  113.  
  114.     if clicktopedale[x.."_"..y] ~= nil then
  115.         itinerari[k].pedale = clicktopedale[x.."_"..y]
  116.  
  117.         term.setBackgroundColor(colors.green)
  118.         term.setCursorPos(x, y)
  119.         term.write(" ")
  120.         term.setBackgroundColor(colors.white)
  121.  
  122.         sleep(2)
  123.     end
  124. end
  125.  
  126. local h3 = fs.open("qlvpedali", "w")
  127. h3.write(textutils.serialize(pedali))
  128. h3.close()
  129.  
  130. local h4 = fs.open("qlvd", "w")
  131. h4.write(textutils.serialize(itinerari))
  132. h4.close()
  133.  
  134. print("\n\nDONEEEEE")
Advertisement
Add Comment
Please, Sign In to add comment