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("Hall", test1, 10,30,3,5) | |
14 | API.setTable("Entrance", test2, 32,52,3,5) | |
15 | API.setTable("Stall lights", test3, 10,30,8,10) | |
16 | API.setTable("Stall power", test4, 32,52,8,10) | |
17 | API.setTable("Doors", test5, 10,52,12,14) | |
18 | API.screen() | |
19 | end | |
20 | ||
21 | function getClick() | |
22 | local _, _, x, y = event.pull(1,touch) | |
23 | if x == nil or y == nil then | |
24 | local h, w = gpu.getResolution() | |
25 | gpu.set(h, w, ".") | |
26 | gpu.set(h, w, " ") | |
27 | else | |
28 | API.checkxy(x,y) | |
29 | end | |
30 | end | |
31 | ||
32 | function test1() | |
33 | API.toggleButton("Hall") | |
34 | if buttonStatus == true then | |
35 | term.setCursor(1,25) | |
36 | term.write("Working... ") | |
37 | rs.setOutput(sides.left,15) | |
38 | os.sleep(1) | |
39 | term.setCursor(1,25) | |
40 | term.write("System ready ") | |
41 | else | |
42 | term.setCursor(1,25) | |
43 | term.write("Working... ") | |
44 | rs.setOutput(sides.left,0) | |
45 | os.sleep(1) | |
46 | term.setCursor(1,25) | |
47 | term.write("System ready ") | |
48 | end | |
49 | end | |
50 | ||
51 | ||
52 | function test2() | |
53 | API.toggleButton("Entrance") | |
54 | if buttonStatus == true then | |
55 | term.setCursor(1,25) | |
56 | term.write("Working... ") | |
57 | rs.setOutput(sides.up,15) | |
58 | os.sleep(1) | |
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.up,0) | |
65 | os.sleep(1) | |
66 | term.setCursor(1,25) | |
67 | term.write("System ready ") | |
68 | end | |
69 | end | |
70 | ||
71 | function test3() | |
72 | API.toggleButton("Stall lights") | |
73 | if buttonStatus == true then | |
74 | term.setCursor(1,25) | |
75 | term.write("Working... ") | |
76 | rs.setOutput(sides.right,15) | |
77 | os.sleep(1) | |
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.right,0) | |
84 | os.sleep(1) | |
85 | term.setCursor(1,25) | |
86 | term.write("System ready ") | |
87 | end | |
88 | end | |
89 | ||
90 | function test4() | |
91 | API.toggleButton("Stall power") | |
92 | if buttonStatus == true then | |
93 | term.setCursor(1,25) | |
94 | term.write("Working... ") | |
95 | rs.setOutput(sides.back,15) | |
96 | os.sleep(1) | |
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(1) | |
104 | term.setCursor(1,25) | |
105 | term.write("System ready ") | |
106 | end | |
107 | end | |
108 | ||
109 | function test5() | |
110 | API.toggleButton("Doors") | |
111 | if buttonStatus == true then | |
112 | term.setCursor(1,25) | |
113 | term.write("Working... ") | |
114 | rs.setOutput(sides.front,15) | |
115 | os.sleep(1) | |
116 | term.setCursor(1,25) | |
117 | term.write("System ready ") | |
118 | else | |
119 | term.setCursor(1,25) | |
120 | term.write("Working... ") | |
121 | rs.setOutput(sides.front,0) | |
122 | os.sleep(1) | |
123 | term.setCursor(1,25) | |
124 | term.write("System ready ") | |
125 | end | |
126 | end | |
127 | ||
128 | term.setCursorBlink(false) | |
129 | gpu.setResolution(80, 25) | |
130 | API.clear() | |
131 | API.fillTable() | |
132 | API.heading("Power control - by maumagro") | |
133 | API.label(1,24,"Buenos Aires, Argentina.") | |
134 | ||
135 | while true do | |
136 | getClick() | |
137 | end | |
138 | ||
139 | ||
140 | ||
141 | --eof |