Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Custom Button Program 0-0-1
- -- 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/ppFqVkXZ
- -- Call API & Set Monitor Location
- os.loadAPI("button")
- m = peripheral.wrap("top")
- m.clear()
- -- Set Button Names and Location
- function fillTable()
- button.setTable("Milk", test1, 10,20,3,5)
- button.setTable("Scorp", test2, 22,32,3,5)
- button.setTable("Uji", test3, 10,20,8,10)
- button.setTable("Death", test4, 22,32,8,10)
- button.screen()
- 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("Milk")
- m.clear()
- m.setCursorPos(1,1)
- m.write("Milk")
- sleep(3)
- shell.run("demo")
- end
- function test2()
- button.flash("Scorp")
- m.clear()
- m.setCursorPos(1,1)
- m.write("Scorp")
- sleep(3)
- shell.run("demo")
- end
- function test3()
- button.flash("Uji")
- m.clear()
- m.setCursorPos(1,1)
- m.write("Uji")
- sleep(3)
- shell.run("demo")
- end
- function test4()
- button.flash("Death")
- m.clear()
- m.setCursorPos(1,1)
- m.write("Rebooting Computer for Updates!")
- sleep(3)
- 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
Advertisement