Advertisement
Guest User

b

a guest
Jul 29th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.72 KB | None | 0 0
  1. --A Computercraft Button Controlpanel with
  2. --the Button API from Direwolf20 by leachiml
  3. os.loadAPI("button")
  4. m = peripheral.wrap("back")
  5. m.clear()
  6. local nbr = 64
  7. function fillTable()
  8.    button.setTable("Spruce Wood", test1, 2,12,3,5)
  9.    button.setTable("SW Plank", test2, 15,25,3,5)
  10.    button.setTable("Oak Wood", test3, 28,38,3,5)
  11.    button.setTable("OW Plank", test5, 2,12,7,9)
  12.    button.setTable("Carrot", test6, 2,12,11,13)
  13.    button.setTable("Charcoal", test7, 2,12,15,17)
  14.    button.setTable("Birch wood", test8, 15,25,7,9)
  15.    button.setTable("BW Plank", test9, 15,25,11,13)
  16.    button.setTable("Sugar Cane", test10, 15,25,15,17)
  17.    button.setTable("+", add, 41,49,11,13)
  18.    button.setTable("-", substract, 41,49,15,17)
  19.    button.setTable("Potatoe", test14, 28,38,7,9)
  20.    button.setTable("Cobble", test15, 28,38,11,13)
  21.    button.setTable("test16", test16, 28,38,15,17)
  22.    button.screen()
  23. end
  24.  
  25. function getClick()
  26.    event,side,x,y = os.pullEvent("monitor_touch")
  27.    button.checkxy(x,y)
  28. end
  29.  
  30. function test1()
  31.    button.flash("Spruce Wood")
  32.    if rs.testBundledInput("left",colors.magenta) == false then
  33.       rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.magenta))
  34.    else
  35.       rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.magenta))
  36.    end
  37.    shell.run("get "..nbr.." SW")
  38. end  
  39.  
  40. function test2()
  41.    button.toggleButton("test2")
  42.    if rs.testBundledInput("left", colors.orange) == false then
  43.       rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.orange))
  44.    else
  45.       rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.orange))
  46.    end      
  47. end
  48.  
  49. function test3()
  50.    button.toggleButton("test3")
  51.    if rs.testBundledInput("left", colors.brown) == false then
  52.       rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.brown))
  53.    else
  54.       rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.brown))
  55.    end      
  56. end
  57.  
  58.  
  59. function test5()
  60.    button.toggleButton("test5")
  61.    if rs.testBundledInput("left", colors.yellow) == false then
  62.       rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.yellow))
  63.    else
  64.       rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.yellow))
  65.    end      
  66. end  
  67.  
  68. function test6()
  69.    button.toggleButton("test6")
  70.    if rs.testBundledInput("left", colors.gray) == false then
  71.       rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.gray))
  72.    else
  73.       rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.gray))
  74.    end      
  75. end
  76.  
  77. function test7()
  78.    button.toggleButton("test7")
  79.    if rs.testBundledInput("left", colors.pink) == false then
  80.       rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.pink))
  81.    else
  82.       rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.pink))
  83.    end      
  84. end
  85.  
  86. function test8()
  87.    button.toggleButton("test8")
  88.    if rs.testBundledInput("left", colors.lime) == false then
  89.       rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.lime))
  90.    else
  91.       rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.lime))
  92.    end      
  93. end
  94.  
  95. function test9()
  96.    button.toggleButton("test9")
  97.    if rs.testBundledInput("left", colors.purple) == false then
  98.       rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.purple))
  99.    else
  100.       rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.purple))
  101.    end      
  102. end
  103.  
  104. function test10()
  105.    button.toggleButton("test10")
  106.    if rs.testBundledInput("left", colors.black) == false then
  107.       rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.black))
  108.    else
  109.       rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.black))
  110.    end      
  111. end
  112.  
  113.  
  114. function add()
  115.    button.flash("+")
  116.    if rs.testBundledInput("left", colors.lightGray) == false then
  117.       rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.lightGray))
  118.    else
  119.       rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.lightGray))
  120.    end
  121.    nbr = nbr + 1
  122.    m.write(nbr)      
  123. end
  124.  
  125. function substract()
  126.    button.flash("-")
  127.    if rs.testBundledInput("left", colors.cyan) == false then
  128.       rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.cyan))
  129.    else
  130.       rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.cyan))
  131.    end
  132.    nbr = nbr - 1
  133.    m.write(nbr)      
  134. end
  135.  
  136. function test14()
  137.    button.toggleButton("test14")
  138.    if rs.testBundledInput("left", colors.blue) == false then
  139.       rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.blue))
  140.    else
  141.       rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.blue))
  142.    end      
  143. end
  144.  
  145. function test15()
  146.    button.toggleButton("test15")
  147.    if rs.testBundledInput("left", colors.green) == false then
  148.       rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.green))
  149.    else
  150.       rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.green))
  151.    end      
  152. end
  153.  
  154. function test16()
  155.    button.toggleButton("test16")
  156.    if rs.testBundledInput("left", colors.red) == false then
  157.       rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.red))
  158.    else
  159.       rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.red))
  160.    end      
  161. end
  162.  
  163. fillTable()
  164. button.heading("Home controll System")
  165.  
  166. while true do
  167.    getClick()
  168. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement