Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Custom Button Program 0-0-2
- -- Works with: Advanced Computer & Monitor
- -- Environment Tested: Minecraft 1.6.4 Computer Craft version 1.5
- -- By RCScorpionfien @
- -- Requires Button API to work, download at pastebin.com/HRbMF1Eg
- -- Download this file >> http://www.pastebin.com/hYWnN9Bb
- -- Call API & Set Paripheral Location
- os.loadAPI("button","redset")
- m = peripheral.wrap("top")
- m.clear()
- rs.setOutput("right", true)
- -- Functions
- -- Set Button Names and Location
- function fillTable()
- button.setTable("Door", test1, 10,20,3,5)
- button.setTable("Test", test2, 22,32,3,5)
- button.setTable("Empty", test3, 10,20,8,10)
- button.setTable("Death", test4, 22,32,8,10)
- button.screen()
- end
- -- Set Lever Combination for door lock
- function cirTest()
- local event = os.pullEvent("redstone")
- local r1 = rs.testBundledInput("back",colors.white)
- local r2 = rs.testBundledInput("back",colors.orange)
- local r3 = rs.testBundledInput("back",colors.magenta)
- local r4 = rs.testBundledInput("back",colors.lightBlue)
- local r5 = rs.testBundledInput("back",colors.yellow)
- local r6 = rs.testBundledInput("back",colors.lime)
- local l1 = rs.testBundledInput("back",colors.red)
- local l2 = rs.testBundledInput("back",colors.green)
- local l3 = rs.testBundledInput("back",colors.brown)
- local l4 = rs.testBundledInput("back",colors.blue)
- local l5 = rs.testBundledInput("back",colors.purple)
- local l6 = rs.testBundledInput("back",colors.cyan)
- if r1 or r3 or r4 or r5 or r6 or l2 or l4 or l5 then
- m.write(" Try Again")
- rs.setOutput("right",true)
- elseif r2 and l1 and l3 and l6 then
- rs.setOutput("right",false)
- m.write(" Welcome")
- else
- m.write(" Try Again")
- rs.setOutput("right",false)
- end
- end
- -- Where was the screen clicked
- function getClick()
- event,side,x,y = os.pullEvent("monitor_touch")
- button.checkxy(x,y)
- end
- -- Write Button Funtions here
- function test1()
- button.flash("Door")
- m.clear()
- m.setCursorPos(15,6)
- m.write("Opening Door!")
- rs.setOutput("right", false)
- sleep(3)
- shell.run("demo")
- end
- function test2()
- button.flash("Test")
- m.clear()
- m.setCursorPos(1,6)
- m.write("Testing Circuits")
- cirTest()
- sleep(3)
- shell.run("demo")
- end
- function test3()
- button.flash("Empty")
- m.clear()
- m.setCursorPos(1,6)
- m.write("This button has no config")
- sleep(3)
- shell.run("demo")
- end
- function test4()
- button.flash("Death")
- m.clear()
- m.setCursorPos(4,6)
- m.write("Rebooting Computer for Updates!")
- sleep(2)
- m.clear()
- shell.run("reboot")
- end
- -- Places Buttons on screen with Heading and Label
- fillTable()
- button.heading("Test Buttons")
- button.label(1,5,"Try Me!")
- -- begin event listener for user Click
- -- An alternate method should be used
- -- while true do is for demonstration purposes only
- while true do
- getClick()
- end
Advertisement
Add Comment
Please, Sign In to add comment