Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- FILLEDBOX
- 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
- -- CODE
- -- Variables
- clicktocolor = {}
- itinerari = {}
- -- Load data
- local h = fs.open("qlvdata-published", "r")
- data = textutils.unserialize(h.readAll())
- h.close()
- function reset()
- term.setBackgroundColor(colors.white)
- term.clear()
- local qlv = paintutils.loadImage("qlv")
- paintutils.drawImage(qlv, 2, 1)
- for k, v in ipairs(data) do
- clicktocolor[v.position.x.."_"..v.position.y] = v.color
- local c = colors.lightGray
- if v.type == "d" then
- c = colors.gray
- end
- term.setBackgroundColor(c)
- drawPixelInternal(v.position.x, v.position.y)
- end
- --term.setTextColor(colors.black)
- --print(textutils.serialize(clicktocolor))
- term.setBackgroundColor(colors.white)
- drawFilledBox(1, 1, 51, 1)
- end
- while true do
- reset()
- term.setCursorPos(12, 1)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.white)
- term.write("CREA ITINERARIO")
- term.setCursorPos(1, 2)
- term.write("Nome:")
- term.setCursorPos(7, 2)
- local name = read()
- if name == "EXIT" then
- break
- end
- term.setCursorPos(5, 3)
- term.write("Seleziona gli enti da attivare")
- --print(textutils.serialize(clicktocolor))
- enti = {}
- while true do
- local ev, bt, x, y = os.pullEvent("mouse_click")
- if y > 17 then
- break
- end
- local pos = x.."_"..y
- local cc = clicktocolor[pos]
- if cc ~= nil then
- table.insert(enti, cc)
- term.setBackgroundColor(colors.red)
- term.setCursorPos(x, y)
- term.write(" ")
- term.setBackgroundColor(colors.white)
- end
- end
- reset()
- term.setCursorPos(12, 1)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.white)
- term.write("BLOCCA ITINERARIO")
- term.setCursorPos(1, 2)
- term.write("Dir. it (s/d):")
- term.setCursorPos(20, 2)
- local dir = read()
- term.setCursorPos(5, 3)
- term.write("Seleziona gli enti da BLOCCARE "..name)
- --print(textutils.serialize(clicktocolor))
- enti_lock = {}
- while true do
- local ev, bt, x, y = os.pullEvent("mouse_click")
- if y > 17 then
- break
- end
- local pos = x.."_"..y
- local cc = clicktocolor[pos]
- if cc ~= nil then
- table.insert(enti_lock, cc)
- term.setBackgroundColor(colors.blue)
- term.setCursorPos(x, y)
- term.write(" ")
- term.setBackgroundColor(colors.white)
- end
- end
- table.insert(itinerari, {name=name,enti=enti,lock=enti_lock,direction=dir})
- end
- local h2 = fs.open("qlvd", "w")
- h2.write(textutils.serialize(itinerari))
- h2.close()
- print("DONEEEE")
Advertisement
Add Comment
Please, Sign In to add comment