Scorpionfien

RC Button Demo

Jun 17th, 2015
716
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. -- Custom Button Program 0-0-2
  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/hYWnN9Bb
  7.  
  8. -- Call API & Set Paripheral Location
  9. os.loadAPI("button","redset")
  10. m = peripheral.wrap("top")
  11. m.clear()
  12. rs.setOutput("right", true)
  13.  
  14. -- Functions
  15. -- Set Button Names and Location
  16. function fillTable()
  17. button.setTable("Door", test1, 10,20,3,5)
  18. button.setTable("Test", test2, 22,32,3,5)
  19. button.setTable("Empty", test3, 10,20,8,10)
  20. button.setTable("Death", test4, 22,32,8,10)
  21. button.screen()
  22. end
  23.  
  24. -- Set Lever Combination for door lock
  25. function cirTest()
  26. local event = os.pullEvent("redstone")
  27. local r1 = rs.testBundledInput("back",colors.white)
  28. local r2 = rs.testBundledInput("back",colors.orange)
  29. local r3 = rs.testBundledInput("back",colors.magenta)
  30. local r4 = rs.testBundledInput("back",colors.lightBlue)
  31. local r5 = rs.testBundledInput("back",colors.yellow)
  32. local r6 = rs.testBundledInput("back",colors.lime)
  33. local l1 = rs.testBundledInput("back",colors.red)
  34. local l2 = rs.testBundledInput("back",colors.green)
  35. local l3 = rs.testBundledInput("back",colors.brown)
  36. local l4 = rs.testBundledInput("back",colors.blue)
  37. local l5 = rs.testBundledInput("back",colors.purple)
  38. local l6 = rs.testBundledInput("back",colors.cyan)
  39.  
  40. if r1 or r3 or r4 or r5 or r6 or l2 or l4 or l5 then
  41. m.write(" Try Again")
  42. rs.setOutput("right",true)
  43. elseif r2 and l1 and l3 and l6 then
  44. rs.setOutput("right",false)
  45. m.write(" Welcome")
  46. else
  47. m.write(" Try Again")
  48. rs.setOutput("right",false)
  49. end
  50. end
  51. -- Where was the screen clicked
  52. function getClick()
  53. event,side,x,y = os.pullEvent("monitor_touch")
  54. button.checkxy(x,y)
  55. end
  56.  
  57. -- Write Button Funtions here
  58. function test1()
  59. button.flash("Door")
  60. m.clear()
  61. m.setCursorPos(15,6)
  62. m.write("Opening Door!")
  63. rs.setOutput("right", false)
  64. sleep(3)
  65. shell.run("demo")
  66. end
  67.  
  68. function test2()
  69. button.flash("Test")
  70. m.clear()
  71. m.setCursorPos(1,6)
  72. m.write("Testing Circuits")
  73. cirTest()
  74. sleep(3)
  75. shell.run("demo")
  76. end
  77.  
  78. function test3()
  79. button.flash("Empty")
  80. m.clear()
  81. m.setCursorPos(1,6)
  82. m.write("This button has no config")
  83. sleep(3)
  84. shell.run("demo")
  85. end
  86.  
  87. function test4()
  88. button.flash("Death")
  89. m.clear()
  90. m.setCursorPos(4,6)
  91. m.write("Rebooting Computer for Updates!")
  92. sleep(2)
  93. m.clear()
  94. shell.run("reboot")
  95. end
  96.  
  97. -- Places Buttons on screen with Heading and Label
  98. fillTable()
  99. button.heading("Test Buttons")
  100. button.label(1,5,"Try Me!")
  101.  
  102. -- begin event listener for user Click
  103. -- An alternate method should be used
  104. -- while true do is for demonstration purposes only
  105. while true do
  106. getClick()
  107. end
Advertisement
Add Comment
Please, Sign In to add comment