Advertisement
HPWebcamAble

[CC][1.0] Advanced Paint

Apr 25th, 2015
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.55 KB | None | 0 0
  1. --Coded by HPWebcamAble--
  2.  
  3. -- Reuploaded per request, It isn't officially supported though --
  4.  
  5. --Colors--
  6. white = 1
  7. orange = 2
  8. magenta = 4
  9. lightBlue = 8
  10. yellow = 16
  11. lime = 32
  12. pink = 64
  13. gray = 128
  14. lightGray = 256
  15. cyan = 512
  16. purple = 1024
  17. blue = 2048
  18. brown = 4096
  19. green = 8192
  20. red = 16384
  21. black = 32768
  22.  
  23. --User Variables--
  24. local ColorMonitor = "monitor_2"  --This has the color selection
  25. local AxilleryMonitor  = "monitor_3" --This has the 'lock' and 'clear' features
  26. local defaultC = white --The default color of the monitors
  27. local monitors= {"monitor_0","monitor_1"} --Any other monitors that are part of the system
  28.  
  29. --Variables--
  30. local version = "1.0"
  31. local p = peripheral.call
  32. local cM = ColorMonitor
  33. local aM = AxilleryMonitor
  34. local lock = false
  35. local bg = "setBackgroundColor"
  36. local bColor = black
  37. local tColor = white
  38. local cBColor = black
  39. local cTColor = white
  40. local clearM = false
  41. local curColor = black
  42. local colors = {white , orange , magenta , lightBlue , yellow , lime , pink , gray , lightGray , cyan , purple , blue , brown , green , red , black}
  43.  
  44. --Functions--
  45. function clear()
  46.   term.clear()
  47.   term.setCursorPos(1,1)
  48. end
  49.  
  50. function type()
  51.   p(cM,"write"," ")
  52. end
  53.  
  54. function drawColorSelection() --Draws the Color Selection
  55.   if lock then
  56.     p(cM,bg,black)
  57.     p(cM,"clear")
  58.     p(cM,"setCursorPos",1,2)
  59.     p(cM,"write","System ")
  60.     p(cM,"setCursorPos",1,3)
  61.     p(cM,"write","Locked ")
  62.   else
  63.   p(cM,bg,curColor)
  64.   p(cM,"clear")
  65.   p(cM,"setCursorPos",2,2)
  66.   for i = 1, 5 do
  67.     p(cM,bg,colors[i])
  68.     type()
  69.   end
  70.   p(cM,"setCursorPos",2,3)
  71.   for i = 1, 5 do
  72.     p(cM,bg,colors[i+5])
  73.     type()
  74.   end
  75.   p(cM,"setCursorPos",2,4)
  76.   for i = 1, 5 do
  77.     p(cM,bg,colors[i+10])
  78.     type()
  79.   end
  80.   end
  81. end
  82.  
  83. function drawAMenu() --Draws the Axillary Menu
  84.   if lock then
  85.     bColor = white
  86.     tColor = black
  87.   else
  88.     bColor = black
  89.     tColor = white
  90.   end
  91.   if clearM then
  92.     cBColor = white
  93.     cTColor = black
  94.   else
  95.     cBColor = black
  96.     cTColor = white
  97.   end
  98.   p(aM,bg,bColor)
  99.   p(aM,"setTextColor",tColor)
  100.   p(aM,"setCursorPos",1,1)
  101.   p(aM,"write","       ")
  102.   p(aM,"setCursorPos",1,2)
  103.   p(aM,"write"," Lock  ")
  104.   p(aM,"setCursorPos",1,3)
  105.   p(aM,bg,lightGray)
  106.   p(aM,"write","       ")
  107.   p(aM,"setCursorPos",1,4)
  108.   p(aM,bg,cBColor)
  109.   p(aM,"setTextColor",cTColor)
  110.   p(aM,"write"," Clear ")
  111.   p(aM,"setCursorPos",1,5)
  112.   p(aM,"write","       ")
  113. end
  114.  
  115.  
  116.  
  117. --Program--
  118. clear()
  119. print("Sarting...")
  120.  
  121. sleep(1)
  122.  
  123. for i = 1, #monitors do
  124.   p(monitors[i],bg,blue)
  125.   p(monitors[i],"clear")
  126. end
  127. p(cM,bg,blue)
  128. p(cM,"clear")
  129. p(aM,bg,blue)
  130. p(aM,"clear")
  131.  
  132. sleep(1)
  133.  
  134. for i = 1, #monitors do
  135.   p(monitors[i],bg,defaultC)
  136.   p(monitors[i],"clear")
  137. end
  138. p(cM,bg,defaultC)
  139. p(cM,"clear")
  140. p(aM,bg,defaultC)
  141. p(aM,"clear")
  142. print("System ready...")
  143. print("LOG:")
  144.  
  145. while true do
  146.   drawColorSelection()
  147.   drawAMenu()
  148.   event,peripheral,x,y = os.pullEvent("monitor_touch")
  149.   print("Touch on " ..peripheral.." at "..x..","..y)
  150.   if peripheral == cM then
  151.     clearM = false
  152.     if x == 2 then
  153.       if y == 1 or y == 5 then
  154.         curColor = black
  155.       elseif y == 2 then
  156.         curColor = white
  157.       elseif y == 3 then
  158.         curColor = lime
  159.       elseif y == 4 then
  160.         curColor = purple
  161.       end
  162.     elseif x == 3 then
  163.       if y == 1 or y == 5 then
  164.         curColor = black
  165.       elseif y == 2 then
  166.         curColor = orange
  167.       elseif y == 3 then
  168.         curColor = pink
  169.       elseif y == 4 then
  170.         curColor = blue
  171.       end
  172.     elseif x == 4 then
  173.       if y == 1 or y == 5 then
  174.         curColor = black
  175.       elseif y == 2 then
  176.         curColor = magenta
  177.       elseif y == 3 then
  178.         curColor = gray
  179.       elseif y == 4 then
  180.         curColor = brown
  181.       end
  182.     elseif x == 5 then
  183.       if y == 1 or y == 5 then
  184.         curColor = black
  185.       elseif y == 2 then
  186.         curColor = lightBlue
  187.       elseif y == 3 then
  188.         curColor = lightGray
  189.       elseif y == 4 then
  190.         curColor = green
  191.       end
  192.     elseif x == 6 then
  193.       if y == 1 or y == 5 then
  194.         curColor = black
  195.       elseif y == 2 then
  196.         curColor = yellow
  197.       elseif y == 3 then
  198.         curColor = cyan
  199.       elseif y == 4 then
  200.         curColor = red
  201.       end
  202.     else
  203.       print("Changing to black...")
  204.       curColor = black
  205.     end
  206.   elseif peripheral == aM then
  207.     if y <= 2 then
  208.       lock = not lock
  209.     elseif y >= 4 then
  210.       clearM = not clearM
  211.     end
  212.   else
  213.     if not lock then
  214.        if clearM then
  215.         p(peripheral,bg,defaultC)
  216.         p(peripheral,"clear")
  217.       else
  218.         p(peripheral,"setCursorPos",x,y)
  219.         p(peripheral,bg,curColor)
  220.         p(peripheral,"write"," ")
  221.       end
  222.     end
  223.   end
  224.   print("Current color:"..curColor)
  225. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement