Advertisement
milkshake

Custom Button Program 0-0-1

Jun 17th, 2015
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.70 KB | None | 0 0
  1. -- Custom Button Program 0-0-1
  2. -- Works with: Advanced Computer & Monitor
  3. -- Environment Tested: Minecraft 1.6.4 Computer Craft version 1.5
  4. -- By RCScorpionfien @
  5. -- Requires Button API to work, download at pastebin.com/HRbMF1Eg
  6. -- Download this file >> http://www.pastebin.com/ppFqVkXZ
  7.  
  8. -- Call API & Set Monitor Location
  9. os.loadAPI("button")
  10. m = peripheral.wrap("top")
  11. m.clear()
  12.  
  13. -- Set Button Names and Location
  14. function fillTable()
  15.    button.setTable("Milk",  test1, 10,20,3,5)
  16.    button.setTable("Scorp", test2, 22,32,3,5)
  17.    button.setTable("Uji",   test3, 10,20,8,10)
  18.    button.setTable("Death", test4, 22,32,8,10)
  19.    button.screen()
  20. end
  21.  
  22. -- Where was the screen clicked
  23. function getClick()
  24.    event,side,x,y = os.pullEvent("monitor_touch")
  25.    button.checkxy(x,y)
  26. end
  27.  
  28. -- Write Button Funtions here
  29. function test1()
  30.    button.flash("Milk")
  31.    m.clear()
  32.    m.setCursorPos(1,1)
  33.    m.write("Milk")
  34.    sleep(3)
  35.    shell.run("demo")
  36. end
  37.  
  38. function test2()
  39.    button.flash("Scorp")
  40.    m.clear()
  41.    m.setCursorPos(1,1)
  42.    m.write("Scorp")
  43.    sleep(3)
  44.    shell.run("demo")
  45. end
  46.  
  47. function test3()
  48.    button.flash("Uji")
  49.    m.clear()
  50.    m.setCursorPos(1,1)
  51.    m.write("Uji")
  52.    sleep(3)
  53.    shell.run("demo")
  54. end
  55.  
  56. function test4()
  57.    button.flash("Death")
  58.    m.clear()
  59.    m.setCursorPos(1,1)
  60.    m.write("Rebooting Computer for Updates!")
  61.    sleep(3)
  62.    m.clear()
  63.    shell.run("reboot")
  64. end
  65.  
  66. -- Places Buttons on screen with Heading and Label
  67. fillTable()
  68. button.heading("Test Buttons")
  69. button.label(1,5,"Try Me!")
  70.  
  71. -- begin event listener for user Click
  72. -- An alternate method should be used
  73. -- while true do is for demonstration purposes only
  74. while true do
  75.    getClick()
  76. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement