SHOW:
|
|
- or go back to the newest paste.
1 | - | term.clear() |
1 | + | local mon = peripheral.wrap("back") |
2 | - | m = peripheral.wrap("top") |
2 | + | function clear() |
3 | - | m.setTextScale(3) |
3 | + | term.clear() |
4 | - | term.setCursorPos(1,1) |
4 | + | term.setCursorPos(1,1) |
5 | - | print(1) |
5 | + | end |
6 | - | term.setCursorPos(1,2) |
6 | + | local response = http.get("http://pastebin.com/raw.php?i=dgse1Ysa") |
7 | - | print("->") |
7 | + | if response then |
8 | - | term.setCursorPos(6,3) |
8 | + | print("Update-suche erfolgreich!") |
9 | - | print("+") |
9 | + | local sSource = response.readAll() |
10 | - | |
10 | + | response.close() |
11 | - | while true do |
11 | + | local file = fs.open( "startup", "r" ) |
12 | - | event,side,x,y = os.pullEvent() |
12 | + | local sTarget = "" |
13 | - | if event == "monitor_touch" then |
13 | + | if file then |
14 | - | if x == 1 and y == 1 then |
14 | + | sTarget = file.readAll() |
15 | - | term.setCursorPos(4,2) |
15 | + | file.close() |
16 | - | print("1") |
16 | + | end |
17 | - | end |
17 | + | if sSource ~= sTarget then |
18 | - | end |
18 | + | term.write("Updates gefunden!") |
19 | file = fs.open( "startup", "w" ) | |
20 | file.write( sSource ) | |
21 | file.close() | |
22 | print( "Wurde herruntergeladen als - startup - -Datei") | |
23 | print("Programm wird Neugestartet!") | |
24 | shell.run("startup") | |
25 | return | |
26 | else | |
27 | print("Es sind keine Updates vorhanden!") | |
28 | print("Programm wird gestartet!") | |
29 | sleep(3) | |
30 | clear() | |
31 | end | |
32 | else | |
33 | clear() | |
34 | print("ERROR! Informiere bitte TheBommel!!") | |
35 | clear() | |
36 | end | |
37 | -------------- Alle Quarry ausschalten nach reboot ---------------------------------------------------------------- | |
38 | rednet.send(277, "off") | |
39 | rednet.send(277, "off") | |
40 | rednet.send(277, "off") | |
41 | rednet.send(277, "off") | |
42 | rednet.send(277, "off") | |
43 | rednet.send(277, "off") | |
44 | ----------------------------------------------------------------------------------------------------------------- | |
45 | rednet.open("top") | |
46 | local mon = peripheral.wrap("back") | |
47 | -- Farbdecodierer | |
48 | function decode(int) | |
49 | if int == 1 then | |
50 | return 1 | |
51 | elseif int == 2 then | |
52 | return 2 | |
53 | elseif int == 3 then | |
54 | return 4 | |
55 | elseif int == 4 then | |
56 | return 8 | |
57 | elseif int == 5 then | |
58 | return 16 | |
59 | elseif int == 6 then | |
60 | return 32 | |
61 | elseif int == 7 then | |
62 | return 64 | |
63 | elseif int == 8 then | |
64 | return 128 | |
65 | elseif int == 9 then | |
66 | return 256 | |
67 | elseif int == 10 then | |
68 | return 512 | |
69 | elseif int == 11 then | |
70 | return 1024 | |
71 | elseif int == 12 then | |
72 | return 2048 | |
73 | elseif int == 13 then | |
74 | return 4096 | |
75 | elseif int == 14 then | |
76 | return 8192 | |
77 | elseif int == 15 then | |
78 | return 16384 | |
79 | elseif int == 16 then | |
80 | return 32768 | |
81 | end | |
82 | end | |
83 | ----------------------------------------------------------------------------------------------------------------- | |
84 | term.clear() | |
85 | mon.setBackgroundColor(decode(16)) | |
86 | mon.setCursorPos(14, 1) | |
87 | mon.write("Quarry-Control") | |
88 | ||
89 | -- Gruener Quarry | |
90 | mon.setBackgroundColor(decode(16)) | |
91 | mon.setCursorPos(10, 5) | |
92 | mon.write("Quarry Gruen") | |
93 | mon.setCursorPos(30, 5) | |
94 | mon.setBackgroundColor(decode(15)) | |
95 | mon.write("ON") | |
96 | mon.setCursorPos(35, 5) | |
97 | mon.setBackgroundColor(decode(14)) | |
98 | mon.write("OFF") | |
99 | mon.setBackgroundColor(decode(16)) | |
100 | ||
101 | -- Roter Quarry | |
102 | ||
103 | mon.setBackgroundColor(decode(16)) | |
104 | mon.setCursorPos(10, 7) | |
105 | mon.write("Quarry Rot") | |
106 | mon.setCursorPos(30,7) | |
107 | mon.setBackgroundColor(decode(15)) | |
108 | mon.write("ON") | |
109 | mon.setCursorPos(35, 7) | |
110 | mon.setBackgroundColor(decode(14)) | |
111 | mon.write("OFF") | |
112 | mon.setBackgroundColor(decode(16)) | |
113 | ||
114 | -- Cyan Quarry | |
115 | ||
116 | mon.setBackgroundColor(decode(16)) | |
117 | mon.setCursorPos(10, 9) | |
118 | mon.write("Quarry Cyan") | |
119 | mon.setCursorPos(30, 9) | |
120 | mon.setBackgroundColor(decode(15)) | |
121 | mon.write("ON") | |
122 | mon.setCursorPos(35, 9) | |
123 | mon.setBackgroundColor(decode(14)) | |
124 | mon.write("OFF") | |
125 | mon.setBackgroundColor(decode(16)) | |
126 | ||
127 | -- Brauner Quarry | |
128 | ||
129 | mon.setBackgroundColor(decode(16)) | |
130 | mon.setCursorPos(10, 11) | |
131 | mon.write("Quarry Braun") | |
132 | mon.setCursorPos(30, 11) | |
133 | mon.setBackgroundColor(decode(15)) | |
134 | mon.write("ON") | |
135 | mon.setCursorPos(35, 11) | |
136 | mon.setBackgroundColor(decode(14)) | |
137 | mon.write("OFF") | |
138 | mon.setBackgroundColor(decode(16)) | |
139 | ||
140 | -- Lime Quarry | |
141 | ||
142 | mon.setBackgroundColor(decode(16)) | |
143 | mon.setCursorPos(10, 13) | |
144 | mon.write("Quarry Lime") | |
145 | mon.setCursorPos(30,13) | |
146 | mon.setBackgroundColor(decode(15)) | |
147 | mon.write("ON") | |
148 | mon.setCursorPos(35, 13) | |
149 | mon.setBackgroundColor(decode(14)) | |
150 | mon.write("OFF") | |
151 | mon.setBackgroundColor(decode(16)) | |
152 | ||
153 | -- Oranger Quarry | |
154 | ||
155 | mon.setBackgroundColor(decode(16)) | |
156 | mon.setCursorPos(10, 15) | |
157 | mon.write("Quarry Orange") | |
158 | mon.setCursorPos(30, 15) | |
159 | mon.setBackgroundColor(decode(15)) | |
160 | mon.write("ON") | |
161 | mon.setCursorPos(35, 15) | |
162 | mon.setBackgroundColor(decode(14)) | |
163 | mon.write("OFF") | |
164 | mon.setBackgroundColor(decode(16)) | |
165 | ----------------------------------------------------------------------------------------------------------------- | |
166 | -- ON/OFF Schaltung | |
167 | -- Gruen ON | |
168 | while true do | |
169 | e,d,x,y = os.pullEvent() | |
170 | if e == "monitor_touch" then | |
171 | if x == 30 and y == 5 then | |
172 | mon.setCursorPos(30, 5) | |
173 | mon.setBackgroundColor(decode(14)) | |
174 | mon.write("ON") | |
175 | mon.setCursorPos(35, 5) | |
176 | mon.setBackgroundColor(decode(15)) | |
177 | mon.write("OFF") | |
178 | g=1 | |
179 | rednet.send(286, "lon") | |
180 | elseif x == 35 and y == 5 and g == 1 then | |
181 | mon.setCursorPos(35, 5) | |
182 | mon.setBackgroundColor(decode(14)) | |
183 | mon.write("OFF") | |
184 | mon.setCursorPos(30,5) | |
185 | mon.setBackgroundColor(decode(15)) | |
186 | mon.write("ON") | |
187 | g=2 | |
188 | rednet.send(286, "loff") | |
189 | ---- | |
190 | elseif x == 30 and y == 7 then | |
191 | mon.setCursorPos(30,7) | |
192 | mon.setBackgroundColor(decode(14)) | |
193 | mon.write("ON") | |
194 | mon.setCursorPos(35, 7) | |
195 | mon.setBackgroundColor(decode(15)) | |
196 | mon.write("OFF") | |
197 | rednet.send(286, "ron") | |
198 | r=1 | |
199 | elseif x == 35 and y == 7 and r == 1 then | |
200 | mon.setCursorPos(30,7) | |
201 | mon.setBackgroundColor(decode(15)) | |
202 | mon.write("ON") | |
203 | mon.setCursorPos(35, 7) | |
204 | mon.setBackgroundColor(decode(14)) | |
205 | mon.write("OFF") | |
206 | rednet.send(286, "roff") | |
207 | r = 0 | |
208 | ------- | |
209 | elseif x == 30 and y == 9 then | |
210 | mon.setCursorPos(30,9) | |
211 | mon.setBackgroundColor(decode(14)) | |
212 | mon.write("ON") | |
213 | mon.setCursorPos(35, 9) | |
214 | mon.setBackgroundColor(decode(15)) | |
215 | mon.write("OFF") | |
216 | rednet.send(285, "lon") | |
217 | c=1 | |
218 | elseif x == 35 and y == 9 and c == 1 then | |
219 | mon.setCursorPos(30,9) | |
220 | mon.setBackgroundColor(decode(15)) | |
221 | mon.write("ON") | |
222 | mon.setCursorPos(35, 9) | |
223 | mon.setBackgroundColor(decode(14)) | |
224 | mon.write("OFF") | |
225 | rednet.send(285, "loff") | |
226 | c = 0 | |
227 | ------- | |
228 | elseif x == 30 and y == 11 then | |
229 | mon.setCursorPos(30,11) | |
230 | mon.setBackgroundColor(decode(14)) | |
231 | mon.write("ON") | |
232 | mon.setCursorPos(35, 11) | |
233 | mon.setBackgroundColor(decode(15)) | |
234 | mon.write("OFF") | |
235 | rednet.send(285, "ron") | |
236 | b=1 | |
237 | elseif x == 35 and y == 11 and b == 1 then | |
238 | mon.setCursorPos(30,11) | |
239 | mon.setBackgroundColor(decode(15)) | |
240 | mon.write("ON") | |
241 | mon.setCursorPos(35, 11) | |
242 | mon.setBackgroundColor(decode(14)) | |
243 | mon.write("OFF") | |
244 | rednet.send(285, "roff") | |
245 | b = 0 | |
246 | ------- | |
247 | elseif x == 30 and y == 13 then | |
248 | mon.setCursorPos(30,13) | |
249 | mon.setBackgroundColor(decode(14)) | |
250 | mon.write("ON") | |
251 | mon.setCursorPos(35, 13) | |
252 | mon.setBackgroundColor(decode(15)) | |
253 | mon.write("OFF") | |
254 | rednet.send(277, "lon") | |
255 | l=1 | |
256 | elseif x == 35 and y == 13 and l == 1 then | |
257 | mon.setCursorPos(30,13) | |
258 | mon.setBackgroundColor(decode(15)) | |
259 | mon.write("ON") | |
260 | mon.setCursorPos(35, 13) | |
261 | mon.setBackgroundColor(decode(14)) | |
262 | mon.write("OFF") | |
263 | rednet.send(277, "loff") | |
264 | l = 0 | |
265 | ------- | |
266 | elseif x == 30 and y == 15 then | |
267 | mon.setCursorPos(30,15) | |
268 | mon.setBackgroundColor(decode(14)) | |
269 | mon.write("ON") | |
270 | mon.setCursorPos(35, 15) | |
271 | mon.setBackgroundColor(decode(15)) | |
272 | mon.write("OFF") | |
273 | rednet.send(277, "ron") | |
274 | o=1 | |
275 | elseif x == 35 and y == 15 and o == 1 then | |
276 | mon.setCursorPos(30,15) | |
277 | mon.setBackgroundColor(decode(15)) | |
278 | mon.write("ON") | |
279 | mon.setCursorPos(35, 15) | |
280 | mon.setBackgroundColor(decode(14)) | |
281 | mon.write("OFF") | |
282 | rednet.send(277, "roff") | |
283 | o = 0 | |
284 | end | |
285 | end | |
286 | end |