SHOW:
|
|
- or go back to the newest paste.
1 | os.loadAPI("ocs/apis/sensor") | |
2 | ||
3 | -- Wrap the sensor | |
4 | ||
5 | for a,b in pairs(rs.getSides()) do | |
6 | if peripheral.getType(b) == 'sensor' then | |
7 | prox = sensor.wrap(b) | |
8 | break | |
9 | end | |
10 | end | |
11 | ||
12 | -- Wrap the monitor | |
13 | ||
14 | for a,b in pairs(rs.getSides()) do | |
15 | if peripheral.getType(b) == 'monitor' then | |
16 | mon = peripheral.wrap(b) | |
17 | break | |
18 | end | |
19 | end | |
20 | ||
21 | term.redirect(mon) | |
22 | ||
23 | -- Battery graphic | |
24 | ||
25 | function low(l,b) | |
26 | term.setCursorPos(l,b) | |
27 | term.setTextColor(colors.red) | |
28 | print("||") | |
29 | term.setTextColor(colors.white) | |
30 | end | |
31 | ||
32 | function medium(l, b) | |
33 | b = b - 1 | |
34 | term.setCursorPos(l, b) | |
35 | term.setTextColor(colors.yellow) | |
36 | print("||") | |
37 | term.setTextColor(colors.white) | |
38 | end | |
39 | ||
40 | function clM(l, b) | |
41 | b = b - 1 | |
42 | term.setCursorPos(l, b) | |
43 | term.setTextColor(colors.black) | |
44 | print("||") | |
45 | term.setTextColor(colors.white) | |
46 | end | |
47 | ||
48 | function high(l, b) | |
49 | b = b - 2 | |
50 | term.setCursorPos(l,b) | |
51 | term.setTextColor(colors.lime) | |
52 | print("||") | |
53 | term.setTextColor(colors.white) | |
54 | end | |
55 | ||
56 | function clH(l, b) | |
57 | b = b - 2 | |
58 | term.setCursorPos(l,b) | |
59 | term.setTextColor(colors.black) | |
60 | print("||") | |
61 | term.setTextColor(colors.white) | |
62 | end | |
63 | ||
64 | -- Battery Function | |
65 | ||
66 | function battery(l,b) | |
67 | if percent < 33 then | |
68 | low(l,b) | |
69 | clM(l,b) | |
70 | clH(l,b) | |
71 | elseif percent >= 33 and percent <= 66 then | |
72 | low(l,b) | |
73 | medium(l,b) | |
74 | clH(l,b) | |
75 | elseif percent >= 66 then | |
76 | low(l,b) | |
77 | medium(l,b) | |
78 | high(l,b) | |
79 | end | |
80 | end | |
81 | ||
82 | while true do | |
83 | ||
84 | shell.run("ui") | |
85 | ||
86 | -- Create table with coordinates | |
87 | ||
88 | t = {} | |
89 | tar = prox.getTargets() | |
90 | i = 1 | |
91 | count = 0 | |
92 | for name, basicDetails in pairs(tar) do | |
93 | ||
94 | local moreDetails = prox.getTargetDetails(name) | |
95 | local checkName = moreDetails.Name | |
96 | if checkName == "MFSU" then | |
97 | t[i] = name | |
98 | i = i+1 | |
99 | count = count + 1 | |
100 | end | |
101 | end | |
102 | ||
103 | -- MFSU 1 | |
104 | if count > 0 then | |
105 | details = prox.getTargetDetails(t[1]) | |
106 | term.setCursorPos(3,3) | |
107 | print("MFSU - 1") | |
108 | term.setCursorPos(4,4) | |
109 | term.setTextColor(colors.black) | |
110 | print("--------") | |
111 | term.setCursorPos(4,4) | |
112 | term.setTextColor(colors.white) | |
113 | print(math.floor(details.Stored)) | |
114 | term.setCursorPos(5,5) | |
115 | term.setTextColor(colors.black) | |
116 | print("-------") | |
117 | term.setCursorPos(5,5) | |
118 | term.setTextColor(colors.white) | |
119 | percent = math.floor(details.StoredPercentage) | |
120 | print(percent, "%") | |
121 | battery(12,5) | |
122 | else | |
123 | term.setCursorPos(4,4) | |
124 | print("No Input") | |
125 | end | |
126 | ||
127 | -- MFSU 2 | |
128 | ||
129 | if count > 1 then | |
130 | details = prox.getTargetDetails(t[2]) | |
131 | term.setCursorPos(20,3) | |
132 | print("MFSU - 2") | |
133 | term.setCursorPos(21,4) | |
134 | term.setTextColor(colors.black) | |
135 | print("--------") | |
136 | term.setCursorPos(21,4) | |
137 | term.setTextColor(colors.white) | |
138 | print(math.floor(details.Stored)) | |
139 | term.setCursorPos(22,5) | |
140 | term.setTextColor(colors.black) | |
141 | print("-------") | |
142 | term.setCursorPos(22,5) | |
143 | term.setTextColor(colors.white) | |
144 | percent = math.floor(details.StoredPercentage) | |
145 | print(percent, "%") | |
146 | battery(29,5) | |
147 | else | |
148 | term.setCursorPos(21,4) | |
149 | print("No Input") | |
150 | end | |
151 | ||
152 | -- MFSU 3 | |
153 | ||
154 | if count > 2 then | |
155 | details = prox.getTargetDetails(t[3]) | |
156 | term.setCursorPos(36,3) | |
157 | print("MFSU - 3") | |
158 | term.setCursorPos(37,4) | |
159 | term.setTextColor(colors.black) | |
160 | print("--------") | |
161 | term.setCursorPos(37,4) | |
162 | term.setTextColor(colors.white) | |
163 | print(math.floor(details.Stored)) | |
164 | term.setCursorPos(38,5) | |
165 | term.setTextColor(colors.black) | |
166 | print("-------") | |
167 | term.setCursorPos(38,5) | |
168 | term.setTextColor(colors.white) | |
169 | percent = math.floor(details.StoredPercentage) | |
170 | print(percent, "%") | |
171 | battery(45,5) | |
172 | else | |
173 | term.setCursorPos(37,4) | |
174 | print("No Input") | |
175 | end | |
176 | ||
177 | -- MFSU 4 | |
178 | ||
179 | if count > 3 then | |
180 | details = prox.getTargetDetails(t[4]) | |
181 | term.setCursorPos(3,9) | |
182 | print("MFSU - 4") | |
183 | term.setCursorPos(4,10) | |
184 | term.setTextColor(colors.black) | |
185 | print("--------") | |
186 | term.setCursorPos(4,10) | |
187 | term.setTextColor(colors.white) | |
188 | print(math.floor(details.Stored)) | |
189 | term.setCursorPos(5,11) | |
190 | term.setTextColor(colors.black) | |
191 | print("-------") | |
192 | term.setCursorPos(5,11) | |
193 | term.setTextColor(colors.white) | |
194 | percent = math.floor(details.StoredPercentage) | |
195 | print(percent, "%") | |
196 | battery(12,11) | |
197 | else | |
198 | term.setCursorPos(4,10) | |
199 | print("No Input") | |
200 | end | |
201 | ||
202 | -- MFSU 5 | |
203 | ||
204 | if count > 4 then | |
205 | details = prox.getTargetDetails(t[5]) | |
206 | term.setCursorPos(20,9) | |
207 | print("MFSU - 5") | |
208 | term.setCursorPos(21,10) | |
209 | term.setTextColor(colors.black) | |
210 | print("--------") | |
211 | term.setCursorPos(21,10) | |
212 | term.setTextColor(colors.white) | |
213 | print(math.floor(details.Stored)) | |
214 | term.setCursorPos(22,11) | |
215 | term.setTextColor(colors.black) | |
216 | print("-------") | |
217 | term.setCursorPos(22,11) | |
218 | term.setTextColor(colors.white) | |
219 | percent = math.floor(details.StoredPercentage) | |
220 | print(percent, "%") | |
221 | battery(29,11) | |
222 | else | |
223 | term.setCursorPos(21,10) | |
224 | print("No Input") | |
225 | end | |
226 | ||
227 | -- MFSU 6 | |
228 | ||
229 | if count > 5 then | |
230 | details = prox.getTargetDetails(t[6]) | |
231 | term.setCursorPos(36,9) | |
232 | print("MFSU - 6") | |
233 | term.setCursorPos(37,10) | |
234 | term.setTextColor(colors.black) | |
235 | print("--------") | |
236 | term.setCursorPos(37,10) | |
237 | term.setTextColor(colors.white) | |
238 | print(math.floor(details.Stored)) | |
239 | term.setCursorPos(38,11) | |
240 | term.setTextColor(colors.black) | |
241 | print("-------") | |
242 | term.setCursorPos(38,11) | |
243 | term.setTextColor(colors.white) | |
244 | percent = math.floor(details.StoredPercentage) | |
245 | print(percent, "%") | |
246 | battery(45,11) | |
247 | else | |
248 | term.setCursorPos(37,10) | |
249 | print("No Input") | |
250 | end | |
251 | ||
252 | ||
253 | sleep(1) | |
254 | ||
255 | end |