SHOW:
|
|
- or go back to the newest paste.
| 1 | API = require("buttonAPI")
| |
| 2 | local event = require("event")
| |
| 3 | local computer = require("computer")
| |
| 4 | local term = require("term")
| |
| 5 | local component = require("component")
| |
| 6 | local gpu = component.gpu | |
| 7 | ||
| 8 | local rs = component.redstone | |
| 9 | local colors = require("colors")
| |
| 10 | local sides = require("sides")
| |
| 11 | ||
| 12 | function API.fillTable() | |
| 13 | API.setTable("Gen 1", test1, 10,20,3,5)
| |
| 14 | API.setTable("Gen 2", test2, 22,32,3,5)
| |
| 15 | API.setTable("Gen 3", test3, 10,20,8,10)
| |
| 16 | API.setTable("Gen 4", test4, 22,32,8,10)
| |
| 17 | API.setTable("Exit", test5, 10,32,13,15)
| |
| 18 | - | API.setTable("Emergency stop", test6, 34,50,3,15)
|
| 18 | + | API.setTable("Emergency stop", test6, 34,62,3,15)
|
| 19 | - | API.setTable("Lights", test7, 52,62,3,5)
|
| 19 | + | |
| 20 | end | |
| 21 | ||
| 22 | function getClick() | |
| 23 | local _, _, x, y = event.pull(1,touch) | |
| 24 | if x == nil or y == nil then | |
| 25 | local h, w = gpu.getResolution() | |
| 26 | gpu.set(h, w, ".") | |
| 27 | gpu.set(h, w, " ") | |
| 28 | else | |
| 29 | API.checkxy(x,y) | |
| 30 | end | |
| 31 | end | |
| 32 | ||
| 33 | function test1() | |
| 34 | API.toggleButton("Gen 1")
| |
| 35 | if buttonStatus == true then | |
| 36 | term.setCursor(1,25) | |
| 37 | term.write("Working... ")
| |
| 38 | rs.setOutput(sides.right,15) | |
| 39 | os.sleep(3) | |
| 40 | term.setCursor(1,25) | |
| 41 | term.write("System ready ")
| |
| 42 | else | |
| 43 | term.setCursor(1,25) | |
| 44 | term.write("Working... ")
| |
| 45 | rs.setOutput(sides.right,0) | |
| 46 | os.sleep(3) | |
| 47 | term.setCursor(1,25) | |
| 48 | term.write("System ready ")
| |
| 49 | end | |
| 50 | end | |
| 51 | ||
| 52 | function test2() | |
| 53 | API.toggleButton("Gen 2")
| |
| 54 | if buttonStatus == true then | |
| 55 | term.setCursor(1,25) | |
| 56 | term.write("Working... ")
| |
| 57 | rs.setOutput(sides.left,15) | |
| 58 | os.sleep(3) | |
| 59 | term.setCursor(1,25) | |
| 60 | term.write("System ready ")
| |
| 61 | else | |
| 62 | term.setCursor(1,25) | |
| 63 | term.write("Working... ")
| |
| 64 | rs.setOutput(sides.left,0) | |
| 65 | os.sleep(3) | |
| 66 | term.setCursor(1,25) | |
| 67 | term.write("System ready ")
| |
| 68 | end | |
| 69 | end | |
| 70 | ||
| 71 | function test3() | |
| 72 | API.toggleButton("Gen 3")
| |
| 73 | if buttonStatus == true then | |
| 74 | term.setCursor(1,25) | |
| 75 | term.write("Working... ")
| |
| 76 | rs.setOutput(sides.front,15) | |
| 77 | os.sleep(3) | |
| 78 | term.setCursor(1,25) | |
| 79 | term.write("System ready ")
| |
| 80 | else | |
| 81 | term.setCursor(1,25) | |
| 82 | term.write("Working... ")
| |
| 83 | rs.setOutput(sides.front,0) | |
| 84 | os.sleep(3) | |
| 85 | term.setCursor(1,25) | |
| 86 | term.write("System ready ")
| |
| 87 | end | |
| 88 | end | |
| 89 | ||
| 90 | function test4() | |
| 91 | API.toggleButton("Gen 4")
| |
| 92 | if buttonStatus == true then | |
| 93 | term.setCursor(1,25) | |
| 94 | term.write("Working... ")
| |
| 95 | rs.setOutput(sides.back,15) | |
| 96 | os.sleep(3) | |
| 97 | term.setCursor(1,25) | |
| 98 | term.write("System ready ")
| |
| 99 | else | |
| 100 | term.setCursor(1,25) | |
| 101 | term.write("Working... ")
| |
| 102 | rs.setOutput(sides.back,0) | |
| 103 | os.sleep(3) | |
| 104 | term.setCursor(1,25) | |
| 105 | term.write("System ready ")
| |
| 106 | end | |
| 107 | end | |
| 108 | ||
| 109 | function test5() | |
| 110 | term.clear() | |
| 111 | os.exit() | |
| 112 | end | |
| 113 | ||
| 114 | function test6() | |
| 115 | term.setCursor(1,25) | |
| 116 | term.write("Working... ")
| |
| 117 | API.flash("Emergency stop",0.25)
| |
| 118 | os.sleep(2) | |
| 119 | rs.setOutput(sides.front,0) | |
| 120 | rs.setOutput(sides.back,0) | |
| 121 | rs.setOutput(sides.right,0) | |
| 122 | rs.setOutput(sides.left,0) | |
| 123 | term.setCursor(1,25) | |
| 124 | term.write("Reactors emergency shutdown! ")
| |
| 125 | os.sleep(1) | |
| 126 | term.setCursor(1,25) | |
| 127 | term.write("System ready ")
| |
| 128 | os.exit() | |
| 129 | end | |
| 130 | ||
| 131 | ||
| 132 | - | function test7() |
| 132 | + | |
| 133 | - | API.toggleButton("Lights")
|
| 133 | + | |
| 134 | API.clear() | |
| 135 | API.fillTable() | |
| 136 | API.heading("McProton. System control module")
| |
| 137 | API.label(1,24,"McPrime 2017. maumagro") | |
| 138 | - | rs.setOutput(sides.up,15) |
| 138 | + | |
| 139 | while true do | |
| 140 | getClick() | |
| 141 | end | |
| 142 | ||
| 143 | ||
| 144 | ||
| 145 | - | rs.setOutput(sides.up,0) |
| 145 | + |