Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --A Computercraft Button Controlpanel with
- --the Button API from Direwolf20 by leachiml
- os.loadAPI("button")
- m = peripheral.wrap("back")
- m.clear()
- local nbr = 64
- function fillTable()
- button.setTable("Spruce Wood", test1, 2,12,3,5)
- button.setTable("SW Plank", test2, 15,25,3,5)
- button.setTable("Oak Wood", test3, 28,38,3,5)
- button.setTable("OW Plank", test5, 2,12,7,9)
- button.setTable("Carrot", test6, 2,12,11,13)
- button.setTable("Charcoal", test7, 2,12,15,17)
- button.setTable("Birch wood", test8, 15,25,7,9)
- button.setTable("BW Plank", test9, 15,25,11,13)
- button.setTable("Sugar Cane", test10, 15,25,15,17)
- button.setTable("+", add, 41,49,11,13)
- button.setTable("-", substract, 41,49,15,17)
- button.setTable("Potatoe", test14, 28,38,7,9)
- button.setTable("Cobble", test15, 28,38,11,13)
- button.setTable("test16", test16, 28,38,15,17)
- button.screen()
- end
- function getClick()
- event,side,x,y = os.pullEvent("monitor_touch")
- button.checkxy(x,y)
- end
- function test1()
- button.flash("Spruce Wood")
- if rs.testBundledInput("left",colors.magenta) == false then
- rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.magenta))
- else
- rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.magenta))
- end
- shell.run("get "..nbr.." SW")
- end
- function test2()
- button.toggleButton("test2")
- if rs.testBundledInput("left", colors.orange) == false then
- rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.orange))
- else
- rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.orange))
- end
- end
- function test3()
- button.toggleButton("test3")
- if rs.testBundledInput("left", colors.brown) == false then
- rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.brown))
- else
- rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.brown))
- end
- end
- function test5()
- button.toggleButton("test5")
- if rs.testBundledInput("left", colors.yellow) == false then
- rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.yellow))
- else
- rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.yellow))
- end
- end
- function test6()
- button.toggleButton("test6")
- if rs.testBundledInput("left", colors.gray) == false then
- rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.gray))
- else
- rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.gray))
- end
- end
- function test7()
- button.toggleButton("test7")
- if rs.testBundledInput("left", colors.pink) == false then
- rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.pink))
- else
- rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.pink))
- end
- end
- function test8()
- button.toggleButton("test8")
- if rs.testBundledInput("left", colors.lime) == false then
- rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.lime))
- else
- rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.lime))
- end
- end
- function test9()
- button.toggleButton("test9")
- if rs.testBundledInput("left", colors.purple) == false then
- rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.purple))
- else
- rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.purple))
- end
- end
- function test10()
- button.toggleButton("test10")
- if rs.testBundledInput("left", colors.black) == false then
- rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.black))
- else
- rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.black))
- end
- end
- function add()
- button.flash("+")
- if rs.testBundledInput("left", colors.lightGray) == false then
- rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.lightGray))
- else
- rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.lightGray))
- end
- nbr = nbr + 1
- m.write(nbr)
- end
- function substract()
- button.flash("-")
- if rs.testBundledInput("left", colors.cyan) == false then
- rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.cyan))
- else
- rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.cyan))
- end
- nbr = nbr - 1
- m.write(nbr)
- end
- function test14()
- button.toggleButton("test14")
- if rs.testBundledInput("left", colors.blue) == false then
- rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.blue))
- else
- rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.blue))
- end
- end
- function test15()
- button.toggleButton("test15")
- if rs.testBundledInput("left", colors.green) == false then
- rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.green))
- else
- rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.green))
- end
- end
- function test16()
- button.toggleButton("test16")
- if rs.testBundledInput("left", colors.red) == false then
- rs.setBundledOutput("left",colors.combine(rs.getBundledOutput("left"), colors.red))
- else
- rs.setBundledOutput("left",colors.subtract(rs.getBundledOutput("left"), colors.red))
- end
- end
- fillTable()
- button.heading("Home controll System")
- while true do
- getClick()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement