FoxWorn3365

qlvtxt

Nov 16th, 2025 (edited)
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.33 KB | None | 0 0
  1. -- FILLEDBOX
  2. local function drawPixelInternal(xPos, yPos)
  3.     term.setCursorPos(xPos, yPos)
  4.     term.write(" ")
  5. end
  6.  
  7. local tColourLookup = {}
  8. for n = 1, 16 do
  9.     tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
  10. end
  11.  
  12. function drawFilledBox(startX, startY, endX, endY, nColour)
  13.     if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
  14.         "number" or type(endY) ~= "number" or
  15.         (nColour ~= nil and type(nColour) ~= "number") then
  16.         error("Expected startX, startY, endX, endY, colour", 2)
  17.     end
  18.  
  19.     startX = math.floor(startX)
  20.     startY = math.floor(startY)
  21.     endX = math.floor(endX)
  22.     endY = math.floor(endY)
  23.  
  24.     if nColour then term.setBackgroundColor(nColour) end
  25.     if startX == endX and startY == endY then
  26.         drawPixelInternal(startX, startY)
  27.         return
  28.     end
  29.  
  30.     local minX = math.min(startX, endX)
  31.     if minX == startX then
  32.         minY = startY
  33.         maxX = endX
  34.         maxY = endY
  35.     else
  36.         minY = endY
  37.         maxX = startX
  38.         maxY = startY
  39.     end
  40.  
  41.     for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
  42. end
  43.  
  44. function qlv()
  45.     term.setBackgroundColor(colors.white)
  46.     term.setTextColor(colors.black)
  47.     titolo("Tangara - ACC")
  48.  
  49.     term.setBackgroundColor(colors.white)
  50.     term.setTextColor(colors.black)
  51.     local qlv = paintutils.loadImage("qlv")
  52.     paintutils.drawImage(qlv, 2, 1)
  53. end
  54.  
  55. -- Variabili da popolare
  56. scritte = {}
  57. scrittepos = {}
  58.  
  59. term.setBackgroundColor(colors.white)
  60. term.clear()
  61. while true do
  62.     qlv()
  63.     term.setCursorPos(12, 1)
  64.     term.setTextColor(colors.black)
  65.     term.setBackgroundColor(colors.white)
  66.  
  67.     term.write("SCRIVI SCRITTE SUL QLV")
  68.  
  69.     for k, v in ipairs(scritte) do
  70.         term.setCursorPos(v.x, v.y)
  71.         term.write(v.text)
  72.     end
  73.  
  74.     local ev, b, x, y = os.pullEvent("mouse_click")
  75.    
  76.     if y > 18 then
  77.         break
  78.     end
  79.  
  80.     if scrittepos[x.."_"..y] ~= nil then
  81.         table.remove(scritte, scrittepos[x.."_"..y])
  82.         scrittepos[x.."_"..y] = nil
  83.     else
  84.         term.setCursorPos(x, y)
  85.         local scritta = read()
  86.  
  87.         if scritta ~= "" and scritta ~= " " then
  88.             table.insert(scritte, {text=scritta,x=x,y=y})
  89.             scrittepos[x.."_"..y] = #scritte
  90.         end
  91.     end
  92. end
  93.  
  94. -- Write
  95. local h = fs.open("qlvtxt", "w")
  96. h.write(textutils.serialize(scritte))
  97. h.close()
  98. print("DONEEE")
Advertisement
Add Comment
Please, Sign In to add comment