SHOW:
|
|
- or go back to the newest paste.
| 1 | - | local args = {...}
|
| 1 | + | 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}
|
| 2 | ||
| 3 | - | local cols = {magenta=colors.magenta, brown=colors.brown, yellow=colors.yellow, lightgray=colors.lightGray, purple=colors.purple, black=colors.black, cyan=colors.cyan, orange=colors.orange, gray=colors.gray, red=colors.red, lime=colors.lime, pink=colors.pink, green=colors.green, lightblue=colors.lightBlue, blue=colors.blue, white=colors.white}
|
| 3 | + | local ender = nil |
| 4 | local coord = {}
| |
| 5 | - | local ender = peripheral.wrap("right")
|
| 5 | + | |
| 6 | local mon = peripheral.find("monitor")
| |
| 7 | - | local col1 = cols[args[1]] |
| 7 | + | |
| 8 | - | local col2 = cols[args[2]] |
| 8 | + | function drawColor(color,row) |
| 9 | - | local col3 = cols[args[3]] |
| 9 | + | local x,y = mon.getCursorPos() |
| 10 | ||
| 11 | - | ender.setColors(col1,col2,col3) |
| 11 | + | local function draw() |
| 12 | mon.setBackgroundColor(color) | |
| 13 | for i=1,3 do | |
| 14 | coord[textutils.serialize({mon.getCursorPos()})] = {color,row}
| |
| 15 | mon.write(" ")
| |
| 16 | end | |
| 17 | mon.setBackgroundColor(colors.black) | |
| 18 | mon.write(" ")
| |
| 19 | end | |
| 20 | ||
| 21 | draw() | |
| 22 | mon.setCursorPos(x,y+1) | |
| 23 | draw() | |
| 24 | mon.setCursorPos(x,y+2) | |
| 25 | draw() | |
| 26 | mon.setCursorPos(x+4,y) | |
| 27 | end | |
| 28 | ||
| 29 | function drawUserInterface() | |
| 30 | mon.setTextScale(0.5) | |
| 31 | mon.clear() | |
| 32 | mon.setCursorPos(1,1) | |
| 33 | coord = {}
| |
| 34 | ||
| 35 | local startX, startY = 4, 2 | |
| 36 | local offset = 4 | |
| 37 | ||
| 38 | local function draw(row) | |
| 39 | local _,Y = mon.getCursorPos() | |
| 40 | for n,c in pairs(cols) do | |
| 41 | if n == 9 then mon.setCursorPos(startX,Y+offset) end | |
| 42 | --coord[textutils.serialize({mon.getCursorPos()})] = c
| |
| 43 | drawColor(c,row) | |
| 44 | end | |
| 45 | end | |
| 46 | ||
| 47 | mon.setCursorPos(startX,startY) | |
| 48 | draw(1) | |
| 49 | mon.setCursorPos(startX,startY + 8) | |
| 50 | draw(2) | |
| 51 | mon.setCursorPos(startX,startY + 16) | |
| 52 | draw(3) | |
| 53 | end | |
| 54 | ||
| 55 | function getColor(x,y,col1,col2,col3) | |
| 56 | local col = coord[textutils.serialize({x,y})]
| |
| 57 | if not col or not col[1] or not col[2] then return col1,col2,col3 end | |
| 58 | if col[2] == 1 then col1 = col[1] | |
| 59 | elseif col[2] == 2 then col2 = col[1] | |
| 60 | elseif col[2] == 3 then col3 = col[1] | |
| 61 | end | |
| 62 | return col1, col2, col3 | |
| 63 | end | |
| 64 | ||
| 65 | function waitForTouchEvent() | |
| 66 | local event, side, monX, monY = os.pullEvent("monitor_touch")
| |
| 67 | ender = peripheral.wrap("right")
| |
| 68 | if not ender then ender = peripheral.wrap("front") end
| |
| 69 | if not ender then return end | |
| 70 | col1, col2, col3 = getColor(monX,monY,ender.getColors()) | |
| 71 | print(col1," ",col2," ",col3) | |
| 72 | ender.setColors(col1,col2,col3) | |
| 73 | end | |
| 74 | ||
| 75 | while true do | |
| 76 | drawUserInterface() | |
| 77 | waitForTouchEvent() | |
| 78 | sleep(0.2) | |
| 79 | end |