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) |
13 | + | API.setTable("Cab 1", test1, 10,20,3,5) |
14 | - | API.setTable("Gen 2", test2, 22,32,3,5) |
14 | + | API.setTable("Hallway", test2, 22,32,3,5) |
15 | - | API.setTable("Gen 3", test3, 10,20,8,10) |
15 | + | API.setTable("Reactors", test3, 10,20,8,10) |
16 | - | API.setTable("Gen 4", test4, 22,32,8,10) |
16 | + | API.setTable("Sec 2", 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("All off", test6, 34,50,3,15) |
19 | - | API.setTable("Lights", test7, 52,62,3,5) |
19 | + | API.setTable("Door", test7, 52,62,3,5) |
20 | API.screen() | |
21 | end | |
22 | ||
23 | function getClick() | |
24 | local _, _, x, y = event.pull(1,touch) | |
25 | if x == nil or y == nil then | |
26 | local h, w = gpu.getResolution() | |
27 | gpu.set(h, w, ".") | |
28 | gpu.set(h, w, " ") | |
29 | else | |
30 | API.checkxy(x,y) | |
31 | end | |
32 | end | |
33 | ||
34 | function test1() | |
35 | - | API.toggleButton("Gen 1") |
35 | + | API.toggleButton("Cab 1") |
36 | if buttonStatus == true then | |
37 | term.setCursor(1,25) | |
38 | term.write("Working... ") | |
39 | rs.setOutput(sides.right,15) | |
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 | term.setCursor(1,25) | |
47 | term.write("System ready ") | |
48 | end | |
49 | end | |
50 | ||
51 | function test2() | |
52 | API.toggleButton("Hallway") | |
53 | if buttonStatus == true then | |
54 | - | API.toggleButton("Gen 2") |
54 | + | |
55 | term.write("Working... ") | |
56 | rs.setOutput(sides.left,15) | |
57 | term.setCursor(1,25) | |
58 | term.write("System ready ") | |
59 | else | |
60 | term.setCursor(1,25) | |
61 | term.write("Working... ") | |
62 | rs.setOutput(sides.left,0) | |
63 | term.setCursor(1,25) | |
64 | term.write("System ready ") | |
65 | end | |
66 | end | |
67 | ||
68 | function test3() | |
69 | API.toggleButton("Reactors") | |
70 | if buttonStatus == true then | |
71 | term.setCursor(1,25) | |
72 | term.write("Working... ") | |
73 | - | API.toggleButton("Gen 3") |
73 | + | |
74 | term.setCursor(1,25) | |
75 | term.write("System ready ") | |
76 | else | |
77 | term.setCursor(1,25) | |
78 | term.write("Working... ") | |
79 | rs.setOutput(sides.front,0) | |
80 | term.setCursor(1,25) | |
81 | term.write("System ready ") | |
82 | end | |
83 | end | |
84 | ||
85 | function test4() | |
86 | API.toggleButton("Sec 2") | |
87 | if buttonStatus == true then | |
88 | term.setCursor(1,25) | |
89 | term.write("Working... ") | |
90 | rs.setOutput(sides.back,15) | |
91 | term.setCursor(1,25) | |
92 | - | API.toggleButton("Gen 4") |
92 | + | |
93 | else | |
94 | term.setCursor(1,25) | |
95 | term.write("Working... ") | |
96 | rs.setOutput(sides.back,0) | |
97 | term.setCursor(1,25) | |
98 | term.write("System ready ") | |
99 | end | |
100 | end | |
101 | ||
102 | function test5() | |
103 | term.clear() | |
104 | os.exit() | |
105 | end | |
106 | ||
107 | function test6() | |
108 | term.setCursor(1,25) | |
109 | term.write("Working... ") | |
110 | API.flash("All off",0.25) | |
111 | os.sleep(2) | |
112 | rs.setOutput(sides.front,0) | |
113 | rs.setOutput(sides.back,0) | |
114 | rs.setOutput(sides.right,0) | |
115 | rs.setOutput(sides.left,0) | |
116 | term.setCursor(1,25) | |
117 | term.write("All lights shu ") | |
118 | - | API.flash("Emergency stop",0.25) |
118 | + | |
119 | term.setCursor(1,25) | |
120 | term.write("System ready ") | |
121 | os.exit() | |
122 | end | |
123 | ||
124 | function test7() | |
125 | - | term.write("Reactors emergency shutdown! ") |
125 | + | API.toggleButton("Door") |
126 | if buttonStatus == true then | |
127 | term.setCursor(1,25) | |
128 | term.write("Working... ") | |
129 | os.sleep(3) | |
130 | rs.setOutput(sides.up,15) | |
131 | term.setCursor(1,25) | |
132 | term.write("System ready ") | |
133 | - | API.toggleButton("Lights") |
133 | + | |
134 | term.setCursor(1,25) | |
135 | term.write("Working... ") | |
136 | os.sleep(3) | |
137 | rs.setOutput(sides.up,0) | |
138 | term.setCursor(1,25) | |
139 | term.write("System ready ") | |
140 | end | |
141 | end | |
142 | ||
143 | term.setCursorBlink(false) | |
144 | gpu.setResolution(80, 25) | |
145 | API.clear() | |
146 | API.fillTable() | |
147 | API.heading("McPrime light control system") | |
148 | API.label(1,24,"McPrime 2017. maumagro") | |
149 | ||
150 | while true do | |
151 | getClick() | |
152 | end | |
153 | ||
154 | ||
155 | - | API.heading("McProton. System control module") |
155 | + | |
156 | --eof |