Advertisement
maxtorcd55

touch_color

Apr 7th, 2014
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.71 KB | None | 0 0
  1. local moni = peripheral.wrap("top")
  2.  
  3. local color1 = 1
  4. local color2 = 1
  5. local color3 = 1
  6. local Tcolor1
  7. local Tcolor2
  8. local Tcolor3
  9.  
  10.  
  11. function backColor(num,colorgroup)
  12.     local colored
  13.     if num == 0 then colored= colors.white end
  14.         if num == 1 then colored= colors.white end
  15.     if num == 2 then colored= colors.orange end
  16.     if num == 3 then colored= colors.magenta end
  17.     if num == 4 then colored= colors.lightBlue end
  18.     if num == 5 then colored= colors.yellow end
  19.     if num == 6 then colored= colors.lime end
  20.     if num == 7 then colored= colors.pink end
  21.     if num == 8 then colored= colors.gray end
  22.         if num == 9 then colored= colors.lightGray end
  23.     if num == 10 then colored= colors.cyan end
  24.     if num == 11 then colored= colors.purple end
  25.     if num == 12 then colored = colors.blue end
  26.     if num == 13 then colored = colors.brown end
  27.     if num == 14 then colored= colors.green end
  28.     if num == 15 then colored= colors.red end
  29.     if num == 16 then colored= colors.black end
  30.     if colorgroup == 1 then Tcolor1 = colored end
  31.     if colorgroup == 2 then Tcolor2 = colored end
  32.     if colorgroup == 3 then Tcolor3 = colored end
  33. end
  34.  
  35. function backNum(num,colorgroup)
  36.     local colored
  37.     if num == colors.white then colored = 1 end
  38.     if num == colors.orange then colored = 2 end
  39.     if num == colors.magenta then colored = 3 end
  40.     if num == colors.lightBlue then colored = 4 end
  41.     if num == colors.yellow then colored = 5 end
  42.     if num == colors.lime then colored = 6 end
  43.     if num == colors.pink then colored = 7 end
  44.     if num == colors.gray then colored = 8 end
  45.     if num == colors.lightGray then colored = 9 end
  46.     if num == colors.cyan then colored = 10 end
  47.     if num == colors.purple then colored = 11 end
  48.     if num == colors.blue then colored = 12 end
  49.     if num == colors.brown then colored = 13 end
  50.     if num == colors.green then colored = 14 end
  51.     if num == colors.red then colored = 15 end
  52.     if num == colors.black then colored = 16 end
  53.     if colorgroup == 1 then color1 = colored end
  54.     if colorgroup == 2 then color2 = colored end
  55.     if colorgroup == 3 then color3 = colored end   
  56. end
  57.  
  58.     backColor(color1,1)
  59.     backColor(color2,2)
  60.     backColor(color3,3)
  61.     moni.setTextColor(colors.red)
  62.     moni.clear()
  63.     moni.setCursorPos(1,1)
  64.     moni.write(" < ")
  65.     moni.setBackgroundColor(tonumber(Tcolor1))
  66.     moni.write(" ")
  67.     moni.setBackgroundColor(colors.black)
  68.     moni.write(" > ")
  69.     moni.setCursorPos(1,2)
  70.     moni.write(" < ")
  71.     moni.setBackgroundColor(tonumber(Tcolor2))
  72.     moni.write(" ")
  73.     moni.setBackgroundColor(colors.black)
  74.     moni.write(" > ")
  75.     moni.setCursorPos(1,3)
  76.     moni.write(" < ")
  77.     moni.setBackgroundColor(tonumber(Tcolor3))
  78.     moni.write(" ")
  79.     moni.setBackgroundColor(colors.black)
  80.     moni.write(" > ")
  81.     moni.setCursorPos(1,4)
  82.     moni.setTextColor(colors.white)
  83.     moni.write("  [?]  ")
  84.     moni.setCursorPos(1,5)
  85.     moni.write("GET|SET")
  86.  
  87. while (true) do
  88.    
  89.     event, side, xPos, yPos = os.pullEvent("monitor_touch")
  90.  
  91.     if (tonumber(xPos) <= 3) and (tonumber(yPos) == 1) then
  92.         if color1 <= 1 then
  93.             color1 = 16
  94.         else
  95.             color1 = color1 - 1
  96.         end
  97.     end
  98.     if (tonumber(xPos) >= 5) and (tonumber(yPos) == 1) then
  99.         if color1 >= 16 then
  100.             color1 = 1
  101.         else
  102.             color1 = color1 + 1
  103.         end
  104.     end
  105.  
  106.     if (tonumber(xPos) <= 3) and (tonumber(yPos) == 2) then
  107.         if color2 <= 1 then
  108.             color2 = 16
  109.         else
  110.             color2 = color2 - 1
  111.         end
  112.     end
  113.     if (tonumber(xPos) >= 5) and (tonumber(yPos) == 2) then
  114.         if color2 >= 16 then
  115.             color2 = 1
  116.         else
  117.             color2 = color2 + 1
  118.         end
  119.     end
  120.     if (tonumber(xPos) <= 3) and (tonumber(yPos) == 3) then
  121.         if color3 <= 1 then
  122.             color3 = 16
  123.         else
  124.             color3 = color3 - 1
  125.         end
  126.     end
  127.     if (tonumber(xPos) >= 5) and (tonumber(yPos) == 3) then
  128.         if color3 >= 16 then
  129.             color3 = 1
  130.         else
  131.             color3 = color3 + 1
  132.         end
  133.     end
  134.  
  135.     if ((tonumber(xPos) >= 3) and (tonumber(xPos) <= 5) ) and (tonumber(yPos) == 4) then
  136.         color1 = math.random(1,16)
  137.         color2 = math.random(1,16)
  138.         color3 = math.random(1,16)
  139.     end
  140.     backColor(color1,1)
  141.     backColor(color2,2)
  142.     backColor(color3,3)
  143.     if ((tonumber(xPos) >= 5) and (tonumber(xPos) <= 7) ) and (tonumber(yPos) == 5) then
  144.         local ender = peripheral.wrap("right")
  145.         if ender ~= nil then
  146.             if string.find(string.lower(peripheral.getType("right")), "chest") then
  147.                 ender.setColors(tonumber(Tcolor1),tonumber(Tcolor2),tonumber(Tcolor3))
  148.             elseif string.find(string.lower(peripheral.getType("right")), "tank") then
  149.                 ender.setColors(tonumber(Tcolor3),tonumber(Tcolor2),tonumber(Tcolor1))
  150.             end
  151.  
  152.         end
  153.     end
  154.     if ((tonumber(xPos) >= 1) and (tonumber(xPos) <= 3) ) and (tonumber(yPos) == 5) then
  155.         local ender = peripheral.wrap("right")
  156.         if ender ~= nil then
  157.             local getcol1
  158.             local getcol2
  159.             local getcol3
  160.             if string.find(string.lower(peripheral.getType("right")), "chest") then
  161.                 getcol1, getcol2, getcol3 = ender.getColors()
  162.             elseif string.find(string.lower(peripheral.getType("right")), "tank") then
  163.                 getcol3, getcol2, getcol1 = ender.getColors()
  164.             end
  165.             backNum(getcol1,1)
  166.             backNum(getcol2,2)
  167.             backNum(getcol3,3)
  168.             backColor(color1,1)
  169.                 backColor(color2,2)
  170.                 backColor(color3,3)
  171.         end
  172.     end
  173.  
  174.    
  175.     moni.setTextColor(colors.red)
  176.     moni.clear()
  177.     moni.setCursorPos(1,1)
  178.     moni.write(" < ")
  179.     moni.setBackgroundColor(tonumber(Tcolor1))
  180.     moni.write(" ")
  181.     moni.setBackgroundColor(colors.black)
  182.     moni.write(" > ")
  183.     moni.setCursorPos(1,2)
  184.     moni.write(" < ")
  185.     moni.setBackgroundColor(tonumber(Tcolor2))
  186.     moni.write(" ")
  187.     moni.setBackgroundColor(colors.black)
  188.     moni.write(" > ")
  189.     moni.setCursorPos(1,3)
  190.     moni.write(" < ")
  191.     moni.setBackgroundColor(tonumber(Tcolor3))
  192.     moni.write(" ")
  193.     moni.setBackgroundColor(colors.black)
  194.     moni.write(" > ")
  195.     moni.setCursorPos(1,4)
  196.     moni.setTextColor(colors.white)
  197.     moni.write("  [?]  ")
  198.     moni.setCursorPos(1,5)
  199.     moni.write("GET|SET")
  200.  
  201.  
  202.  
  203.  
  204. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement