Guest User

Control Panel Alpha 0.6

a guest
May 7th, 2012
7
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function l()
  2.         print("")
  3.     end
  4.      
  5.     function cl()
  6.         term.setCursorPos(1,1)
  7.         term.clear()
  8.     end
  9.      
  10.     function lane()
  11.         print("Control Panel Alpha 0.1")
  12.         l()
  13.     end
  14.      
  15.     local function addoutput(sside, ...)
  16.         local c = colors.combine(rs.getBundledOutput(sside), ...)
  17.         rs.setBundledOutput(sside, c)
  18.     end
  19.      
  20.     local function removeoutput(sside, ...)
  21.        local c = colors.subtract(rs.getBundledOutput(sside), ...)    
  22.        rs.setBundledOutput(sside, c)
  23.     end
  24.      
  25.     function outputanaus(testside)
  26.  
  27.         input = io.read()
  28.             if input == "1" and rs.testBundledInput(testside, 1) then
  29.             removeoutput(testside, 1)
  30.        
  31.             elseif input == "2" and rs.testBundledInput(testside, 2) then
  32.             removeoutput(testside, 2)
  33.            
  34.             elseif input == "3" and rs.testBundledInput(testside, 4) then
  35.             removeoutput(testside, 4)
  36.            
  37.             elseif input == "4" and rs.testBundledInput(testside, 8) then
  38.             removeoutput(testside, 8)
  39.            
  40.             elseif input == "5" and rs.testBundledInput(testside, 16) then
  41.             removeoutput(testside, 16)
  42.            
  43.             elseif input == "6" and rs.testBundledInput(testside, 32) then
  44.             removeoutput(testside, 32)
  45.            
  46.             elseif input == "7" and rs.testBundledInput(testside, 64) then
  47.             removeoutput(testside, 64)
  48.            
  49.             elseif input == "8" and rs.testBundledInput(testside, 128) then
  50.             removeoutput(testside, 128)
  51.            
  52.             elseif input == "9" and rs.testBundledInput(testside, 256) then
  53.             removeoutput(testside, 256)
  54.            
  55.             elseif input == "10" and rs.testBundledInput(testside, 512) then
  56.             removeoutput(testside, 512)
  57.            
  58.             elseif input == "11" and rs.testBundledInput(testside, 1024) then
  59.             removeoutput(testside, 1024)
  60.            
  61.             elseif input == "12" and rs.testBundledInput(testside, 2048) then
  62.             removeoutput(testside, 2048)
  63.            
  64.             elseif input == "13" and rs.testBundledInput(testside, 4096) then
  65.             removeoutput(testside, 4096)
  66.            
  67.             elseif input == "14" and rs.testBundledInput(testside, 8192) then
  68.             removeoutput(testside, 8192)
  69.            
  70.             elseif input == "15" and rs.testBundledInput(testside, 16384) then
  71.             removeoutput(testside, 16384)
  72.            
  73.             elseif input == "16" and rs.testBundledInput(testside, 32768) then
  74.             removeoutput(testside, 32768)
  75.            
  76.             elseif input == "1" then
  77.             addoutput(testside, 1)
  78.        
  79.             elseif input == "2" then
  80.             addoutput(testside, 2)
  81.            
  82.             elseif input == "3" then
  83.             addoutput(testside, 4)
  84.            
  85.             elseif input == "4" then
  86.             addoutput(testside, 8)
  87.            
  88.             elseif input == "5" then
  89.             addoutput(testside, 16)
  90.            
  91.             elseif input == "6" then
  92.             addoutput(testside, 32)
  93.            
  94.             elseif input == "7" then
  95.             addoutput(testside, 64)
  96.            
  97.             elseif input == "8" then
  98.             addoutput(testside, 128)
  99.            
  100.             elseif input == "9" then
  101.             addoutput(testside, 256)
  102.            
  103.             elseif input == "10" then
  104.             addoutput(testside, 512)
  105.            
  106.             elseif input == "11" then
  107.             addoutput(testside, 1024)
  108.            
  109.             elseif input == "12" then
  110.             addoutput(testside, 2048)
  111.            
  112.             elseif input == "13" then
  113.             addoutput(testside, 4096)
  114.            
  115.             elseif input == "14" then
  116.             addoutput(testside, 8192)
  117.            
  118.             elseif input == "15" then
  119.             addoutput(testside, 16384)
  120.            
  121.             elseif input == "16" then
  122.             addoutput(testside, 32768)
  123.            
  124.             elseif input == "q" then
  125.             sleep(0.5)
  126.             return menu()
  127.            
  128.         end
  129.     end
  130.      
  131.    
  132.            
  133.            
  134.         end
  135.     end
  136.      
  137.     function testoutput(testside)
  138.      
  139.         while true do
  140.        
  141.         cl()
  142.         print("(q) Menu")    
  143.      
  144.         if rs.testBundledInput(testside, colors.white) then
  145.                 print("White    : (1) AN")
  146.             else
  147.                 print("White    : Aus")
  148.             end
  149.             if rs.testBundledInput(testside, colors.orange) then
  150.                 print("Orange   : (2) AN")
  151.             else
  152.                 print("Orange   : Aus")
  153.             end
  154.             if rs.testBundledInput(testside, colors.magenta) then
  155.                 print("Magenta  : (3) AN")
  156.             else
  157.                 print("Magenta  : Aus")
  158.             end
  159.             if rs.testBundledInput(testside, 8) then
  160.                 print("LightBlue: (4) AN")
  161.             else
  162.                 print("LightBlue: Aus")
  163.             end
  164.             if rs.testBundledInput(testside, colors.yellow) then
  165.                 print("Yellow   : (5) AN")
  166.             else
  167.                 print("Yellow   : Aus")
  168.             end
  169.         if rs.testBundledInput(testside, colors.lime) then
  170.                 print("Lime     : (6) AN")
  171.             else
  172.                 print("Lime     : Aus")
  173.             end
  174.             if rs.testBundledInput(testside, colors.pink) then
  175.                 print("Pink     : (7) AN")
  176.             else
  177.                 print("Pink     : Aus")
  178.             end
  179.             if rs.testBundledInput(testside, colors.gray) then
  180.                 print("Gray     : (8) AN")
  181.             else
  182.                 print("Gray     : Aus")
  183.             end
  184.             if rs.testBundledInput(testside, 256) then
  185.                 print("LightGray: (9) AN")
  186.             else
  187.                 print("LightGray: Aus")
  188.             end
  189.             if rs.testBundledInput(testside, colors.cyan) then
  190.                 print("Cyan     : (10) AN")
  191.             else
  192.                 print("Cyan     : Aus")
  193.             end
  194.             if rs.testBundledInput(testside, colors.purple) then
  195.                 print("Purple   : (11) AN")
  196.             else
  197.                 print("Purple   : Aus")
  198.             end
  199.             if rs.testBundledInput(testside, colors.blue) then
  200.                 print("Blue     : (12) AN")
  201.             else
  202.                 print("Blue     : Aus")
  203.             end
  204.             if rs.testBundledInput(testside, colors.brown) then
  205.                 print("Brown    : (13) AN")
  206.             else
  207.                 print("Brown    : Aus")
  208.             end
  209.             if rs.testBundledInput(testside, colors.green) then
  210.                 print("Green    : (14) AN")
  211.             else
  212.                 print("Green    : Aus")
  213.             end
  214.             if rs.testBundledInput(testside, colors.red) then
  215.                 print("Red      : (15) AN")
  216.             else
  217.                 print("Red      : Aus")
  218.             end
  219.             if rs.testBundledInput(testside, colors.black) then
  220.                 print("Black    : (16) AN")
  221.             else
  222.                 print("Black    : Aus")
  223.             end
  224.      
  225.     sleep(1)
  226.      
  227.      outputanaus(testside)
  228.      
  229.     sleep(1.5)
  230.  
  231.     return testoutput(testside)
  232.  
  233.      end
  234.     end    
  235.      
  236.     function output()
  237.      
  238.         cl()
  239.         lane()
  240.         print("Output Seite waehlen")
  241.         l()                              -- 20
  242.         print("(1) back")
  243.         print("(2) right")
  244.         print("(3) left")
  245.         print("(4) top")
  246.         print("(5) bottom")
  247.      
  248.         while true do
  249.      
  250.             local e1, p1 = os.pullEvent()
  251.             if e1 == "char" and p1 == "1" then
  252.                 color("back")
  253.             elseif e1 == "char" and p1 == "2" then
  254.                 color("right")
  255.             elseif e1 == "char" and p1 == "3" then
  256.                 color("left")
  257.             elseif e1 == "char" and p1 == "4" then
  258.                 color("top")
  259.             elseif e1 == "char" and p1 == "5" then
  260.                 color("bottom")
  261.              end
  262.             end                        
  263.      
  264.     end
  265.      
  266.      
  267.     function color(side)
  268.         cl()
  269.         lane()
  270.         print("Ausgewaehlte Seite: " ..side)
  271.         print("Bitte Farbe eintippen")
  272.         farbe = io.read()
  273.         if farbe == "white" then
  274.             id = 1
  275.         elseif farbe == "orange" then
  276.             id = 2
  277.         elseif farbe == "magenta" then
  278.             id = 4
  279.         elseif farbe == "lightblue" then
  280.             id = 8
  281.         elseif farbe == "yellow" then
  282.             id = 16
  283.         elseif farbe == "lime" then
  284.             id = 32
  285.         elseif farbe == "pink" then
  286.             id = 64
  287.         elseif farbe == "gray" then
  288.             id = 128
  289.         elseif farbe == "lightgray" then
  290.             id = 256
  291.         elseif farbe == "cyan" then
  292.             id = 512
  293.         elseif farbe == "purple" then
  294.             id = 1024
  295.         elseif farbe == "blue" then
  296.             id = 2048
  297.         elseif farbe == "brown" then
  298.             id = 4096
  299.         elseif farbe == "green" then
  300.             id = 8192
  301.         elseif farbe == "red" then
  302.             id = 16384
  303.         elseif farbe == "black" then
  304.             id = 32768
  305.        end
  306.      
  307.         print(farbe.. " wurde ausgewaehlt")
  308.         sleep(2)
  309.         addoutput(side, id)
  310.         sleep(0.5)
  311.      
  312.        return menu()
  313.      
  314.     end
  315.      
  316.     function status()
  317.      
  318.         cl()
  319.         lane()
  320.         print("Output Seite waehlen")
  321.         l()                              
  322.         print("(1) back")
  323.         print("(2) right")
  324.         print("(3) left")
  325.         print("(4) top")
  326.         print("(5) bottom")
  327.      
  328.         while true do
  329.      
  330.             local e1, p1 = os.pullEvent()
  331.             if e1 == "char" and p1 == "1" then
  332.                 testoutput("back")
  333.             elseif e1 == "char" and p1 == "2" then
  334.                 testoutput("right")
  335.             elseif e1 == "char" and p1 == "3" then
  336.                 testoutput("left")
  337.             elseif e1 == "char" and p1 == "4" then
  338.                 testoutput("top")
  339.             elseif e1 == "char" and p1 == "5" then
  340.                 testoutput("bottom")
  341.                 end
  342.         end                          
  343.      
  344.        
  345.        
  346.     end
  347.      
  348.     function menu()
  349.         cl()  
  350.         lane()
  351.         print("(a) Output setzen")
  352.         print("(b) Status und Abschaltung")
  353.        
  354.         while true do
  355.      
  356.             local event, param = os.pullEvent()
  357.             if event == "char" and param == "a" then
  358.                 output()
  359.                
  360.             elseif event == "char" and param == "b" then
  361.                 status()
  362.             end
  363.         end
  364.     end
  365.      
  366.     menu()
Advertisement
Add Comment
Please, Sign In to add comment