Advertisement
Darking560

touch pixek

Sep 19th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.00 KB | None | 0 0
  1. m = peripheral.wrap('left')
  2. p = peripheral.wrap('top')
  3. color = colors.red
  4.  
  5. function screen()
  6.     m.setBackgroundColor(colors.black)
  7.     m.clear()
  8.     p.setBackgroundColor(colors.black)
  9.     p.clear()
  10.     term.redirect(p)
  11.     paintutils.drawPixel(1,1,colors.gray)
  12.     paintutils.drawPixel(2,1,colors.black)
  13.     paintutils.drawPixel(3,1,colors.red)
  14.     paintutils.drawPixel(4,1,colors.yellow)
  15.     paintutils.drawPixel(1,2,colors.white)
  16.     term.setCursorPos(1,2)
  17.     term.setTextColor(colors.black)
  18.     term.write("T")
  19.     term.setTextColor(colors.white)
  20.     paintutils.drawPixel(3,2,colors.purple)
  21.     term.setCursorPos(1,5)
  22.     x, y = m.getSize()
  23.     term.setBackgroundColor(colors.black)
  24.     term.write(x..";"..y)
  25.     term.restore()
  26.     term.redirect(m)
  27. end
  28.  
  29. screen()
  30.  
  31. while true do
  32.     event, side, xPos, yPos = os.pullEvent()
  33.     if event == "monitor_resize" then
  34.         term.restore()
  35.         screen()
  36.     end
  37.     if event == "monitor_touch" then
  38.     p.setCursorPos(1,3)
  39.     p.write("X: " .. tostring(xPos))
  40.     p.setCursorPos(1,4)
  41.     p.write("Y: " .. tostring(yPos))
  42.     if side == "top" then
  43.         if xPos == 1 and yPos == 1 then
  44.             m.setBackgroundColor(colors.black)
  45.             m.clear()
  46.         elseif yPos == 1 and xPos == 2 then
  47.             color = colors.black
  48.         elseif yPos == 1 and xPos == 3 then
  49.             color = colors.red
  50.         elseif yPos == 1 and xPos == 4 then
  51.             color = colors.yellow
  52.         elseif yPos == 2 and xPos == 1 then
  53.             side = "lol"
  54.             while side ~= "left" do
  55.                 event, side, xPos, yPos = os.pullEvent("monitor_touch")    
  56.             end
  57.             paintutils.drawPixel(xPos, yPos, colors.green)
  58.             term.restore()
  59.             print("Text : ")
  60.             text = read()
  61.             term.redirect(m)
  62.             term.setCursorPos(xPos,yPos)
  63.             term.setBackgroundColor(color)
  64.             term.write(text)
  65.         elseif yPos == 2 and xPos == 3 then
  66.             term.restore()
  67.             print("cmd : ")
  68.             text = read()
  69.             if text == "exit" then exit() end
  70.             if text == "screen" then screen()
  71.             elseif text == "rien" then
  72.             else
  73.                     m.setTextScale(tonumber(text))
  74.             end
  75.             term.redirect(m)
  76.         end
  77.     else
  78.     paintutils.drawPixel(xPos, yPos, color)
  79.     end
  80.     end
  81. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement