Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local cols = {colors.black, colors.gray, colors.lightGray, colors.white, colors.pink, colors.magenta, colors.purple, colors.red, colors.lightBlue, colors.blue, colors.cyan, colors.green, colors.lime, colors.yellow, colors.orange, colors.brown}
- local ender = nil
- local coord = {}
- local mon = peripheral.find("monitor")
- function drawColor(color,row)
- local x,y = mon.getCursorPos()
- local function draw()
- mon.setBackgroundColor(color)
- for i=1,3 do
- coord[textutils.serialize({mon.getCursorPos()})] = {color,row}
- mon.write(" ")
- end
- mon.setBackgroundColor(colors.black)
- mon.write(" ")
- end
- draw()
- mon.setCursorPos(x,y+1)
- draw()
- mon.setCursorPos(x,y+2)
- draw()
- mon.setCursorPos(x+4,y)
- end
- function drawUserInterface()
- mon.setTextScale(0.5)
- mon.clear()
- mon.setCursorPos(1,1)
- coord = {}
- local startX, startY = 4, 2
- local offset = 4
- local function draw(row)
- local _,Y = mon.getCursorPos()
- for n,c in pairs(cols) do
- if n == 9 then mon.setCursorPos(startX,Y+offset) end
- --coord[textutils.serialize({mon.getCursorPos()})] = c
- drawColor(c,row)
- end
- end
- mon.setCursorPos(startX,startY)
- draw(1)
- mon.setCursorPos(startX,startY + 8)
- draw(2)
- mon.setCursorPos(startX,startY + 16)
- draw(3)
- end
- function getColor(x,y,col1,col2,col3)
- local col = coord[textutils.serialize({x,y})]
- if not col or not col[1] or not col[2] then return col1,col2,col3 end
- if col[2] == 1 then col1 = col[1]
- elseif col[2] == 2 then col2 = col[1]
- elseif col[2] == 3 then col3 = col[1]
- end
- return col1, col2, col3
- end
- function waitForTouchEvent()
- local event, side, monX, monY = os.pullEvent("monitor_touch")
- ender = peripheral.wrap("right")
- if not ender then ender = peripheral.wrap("front") end
- if not ender then return end
- col1, col2, col3 = getColor(monX,monY,ender.getColors())
- print(col1," ",col2," ",col3)
- ender.setColors(col1,col2,col3)
- end
- while true do
- drawUserInterface()
- waitForTouchEvent()
- sleep(0.2)
- end
Advertisement
Add Comment
Please, Sign In to add comment