Advertisement
Guest User

monpaint

a guest
Jan 9th, 2014
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.89 KB | None | 0 0
  1. mon = peripheral.wrap("right")
  2. local width, height = mon.getSize()
  3. col = colors.orange
  4.  
  5. function setup()
  6.   mon.clear()
  7.   mon.setCursorPos(1,1)
  8.   mon.setBackgroundColor(colors.black)
  9.   mon.clear()
  10. end
  11.  
  12. divheight = height/2
  13. midheight = math.floor(divheight)  
  14.  
  15.      
  16. function clickScreen()
  17.   while true do
  18.     event, side, xPos, yPos = os.pullEvent("monitor_touch")
  19.     mon.setCursorPos(xPos, yPos)
  20.     if yPos == height then
  21.       mon.setBackgroundColor(colors.black)
  22.       mon.clear()
  23.       clearBar()
  24.     elseif xPos == width then
  25.       colorChange()
  26.     elseif xPos == width-1 then
  27.       colorChange()
  28.     else
  29.       term.redirect(mon)
  30.       paintutils.drawPixel(xPos, yPos, col)
  31.       term.restore()
  32.     end
  33.   end
  34. end
  35.  
  36. function clearBar()
  37.   mon.setCursorPos(1,height)
  38.   mon.setBackgroundColor(colors.red)
  39.   mon.clearLine()
  40.   mon.write("[Clear]")
  41.   mon.setBackgroundColor(colors.black)
  42.   colorBar()
  43. end
  44.  
  45. function colorBar()
  46.   term.redirect(mon)
  47.   paintutils.drawPixel(width, 1, colors.white)
  48.   paintutils.drawPixel(width, 2, colors.orange)
  49.   paintutils.drawPixel(width, 3, colors.magenta)
  50.   paintutils.drawPixel(width, 3, colors.lightBlue)
  51.   paintutils.drawPixel(width, 4, colors.yellow)
  52.   paintutils.drawPixel(width, 5, colors.lime)
  53.      paintutils.drawPixel(width, 6, colors.pink)
  54.      paintutils.drawPixel(width, 7, colors.gray)
  55.      paintutils.drawPixel(width, 8, colors.lightGray)
  56.      paintutils.drawPixel(width, 9, colors.cyan)
  57.      paintutils.drawPixel(width, 10, colors.purple)
  58.      paintutils.drawPixel(width, 11, colors.blue)
  59.      paintutils.drawPixel(width, 12, colors.brown)
  60.      paintutils.drawPixel(width, 13, colors.green)
  61.      paintutils.drawPixel(width, 14, colors.red)
  62.   mon.setBackgroundColor(colors.black)
  63.   term.setCursorPos(width, 15)
  64.   term.setTextColor(colors.white)
  65.   term.write("X")
  66.   term.restore()
  67. end
  68.  
  69. function colorChange()
  70.   if xPos == width and yPos == 1 then
  71.    col = colors.white
  72.   elseif xPos == width and yPos == 2 then
  73.    col = colors.orange
  74.   elseif xPos == width and yPos == 3 then
  75.    col = colors.lightBlue
  76.   elseif xPos == width and yPos == 4 then
  77.    col = colors.yellow
  78.   elseif xPos == width and yPos == 5 then
  79.    col = colors.lime
  80.   elseif xPos == width and yPos == 6 then
  81.    col = colors.pink
  82.   elseif xPos == width and yPos == 7 then
  83.    col = colors.gray
  84.   elseif xPos == width and yPos == 8 then
  85.    col = colors.lightGray
  86.   elseif xPos == width and yPos == 9 then
  87.    col = colors.cyan
  88.   elseif xPos == width and yPos == 10 then
  89.    col = colors.purple
  90.   elseif xPos == width and yPos == 11 then
  91.    col = colors.blue
  92.   elseif xPos == width and yPos == 12 then
  93.    col = colors.brown
  94.   elseif xPos == width and yPos == 13 then
  95.    col = colors.green
  96.   elseif xPos == width and yPos == 14 then
  97.    col = colors.red
  98.   elseif xPos == width and yPos == 15 then
  99.    col = colors.black
  100.   end
  101. end
  102.  
  103. setup()
  104. colorBar()
  105. clearBar()
  106. clickScreen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement