Guest User

Control Panel Alpha 0.4

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