SHOW:
|
|
- or go back to the newest paste.
1 | - | sle = 60 |
1 | + | |
2 | sen = sensor.wrap("bottom") | |
3 | mon = peripheral.wrap("left") | |
4 | state = false | |
5 | ||
6 | mon.setTextScale(1) | |
7 | mon.clear() | |
8 | ||
9 | ||
10 | function formatNumber(number) | |
11 | local formatted = tostring(number) | |
12 | local k = #formatted % 3 | |
13 | if k == 0 then k = 3 end | |
14 | local result = formatted:sub(1, k) | |
15 | while k < #formatted do | |
16 | result = result .. "." .. formatted:sub(k + 1, k + 3) | |
17 | k = k + 3 | |
18 | end | |
19 | return result | |
20 | end | |
21 | ||
22 | ||
23 | ||
24 | while true do | |
25 | s = sen.getTargets() | |
26 | function getS() | |
27 | for v, k in pairs(s) do | |
28 | if k.Name == "ME Wireless Access Point" then | |
29 | target = v | |
30 | - | lv2 = k.Size |
30 | + | |
31 | - | print("LV Rechenwert 2: "..lv2) |
31 | + | |
32 | - | calc = lv2 - lv1 |
32 | + | |
33 | - | calc2 = calc * 60 |
33 | + | |
34 | - | mon.setCursorPos(1,2) |
34 | + | |
35 | - | mon.write("LV Solars/min: "..calc) |
35 | + | |
36 | - | mon.setCursorPos(1,3) |
36 | + | |
37 | - | mon.write("LV Solars/h: "..calc2) |
37 | + | |
38 | - | mon.setCursorPos(1,8) |
38 | + | |
39 | - | mon.write("LVs auf Lager: "..lv2) |
39 | + | mon.setTextColor(colors.yellow) |
40 | if k.Name == "Low Voltage Solar Array" then | |
41 | if state == false then | |
42 | lv1 = k.Size | |
43 | print("LV Rechenwert 1: "..lv1) | |
44 | elseif state == true then | |
45 | lv2 = k.Size | |
46 | print("LV IstWert 2: "..lv2) | |
47 | - | print("UU Rechenwert 1: "..uu1) |
47 | + | calc = (lv2 - lv1) * 6 --LVs pro Minute |
48 | calc2 = calc * 60 --LVs pro Stunde | |
49 | ||
50 | - | print("UU Rechenwert 2: "..uu2) |
50 | + | fN1 = formatNumber(calc) |
51 | - | calc = uu2 - uu1 |
51 | + | fN2 = formatNumber(calc2) |
52 | - | uu3 = uu2 + 1 |
52 | + | fN3 = formatNumber(lv2) |
53 | if calc >= 0 then | |
54 | - | mon.setCursorPos(1,5) |
54 | + | mon.setCursorPos(2,2) |
55 | - | mon.write("UU-Matter/min: "..calc) |
55 | + | mon.write("LV Solars/m: "..fN1 .." ") |
56 | - | mon.setCursorPos(1,6) |
56 | + | else |
57 | - | mon.write("UU-Matter/h: "..calc2) |
57 | + | mon.setCursorPos(2,2) |
58 | - | mon.setCursorPos(1,10) |
58 | + | mon.write("LV Solars/m: 0 ") |
59 | - | mon.write(" UU auf Lager: "..uu3) |
59 | + | end |
60 | if calc2 >= 0 then | |
61 | mon.setCursorPos(2,3) | |
62 | mon.write("LV Solars/h: "..fN2 .." ") | |
63 | else | |
64 | - | if state == true then |
64 | + | mon.setCursorPos(2,3) |
65 | - | hv = k.Size |
65 | + | mon.write("LV Solars/h: 0 ") |
66 | - | print("HV Istwert: "..hv) |
66 | + | end |
67 | - | mon.setCursorPos(1,9) |
67 | + | mon.setCursorPos(2,8) |
68 | - | mon.write("HVs auf Lager: "..hv) |
68 | + | mon.write("LVs on stock: "..fN3 .." ") |
69 | else | |
70 | print("Error(1)") | |
71 | end | |
72 | ||
73 | elseif k.Name == "UU-Matter" then | |
74 | if state == false then | |
75 | uu1 = k.Size | |
76 | print("UU Rechenwert 1: "..uu1) | |
77 | - | sleep(sle) |
77 | + | |
78 | uu2 = k.Size | |
79 | print("UU IstWert 2: "..uu2) | |
80 | calc = (uu2 - uu1) * 6 | |
81 | calc2 = calc * 60 | |
82 | ||
83 | fN4 = formatNumber(calc) | |
84 | fN5 = formatNumber(calc2) | |
85 | fN6 = formatNumber(uu2) | |
86 | if calc >= 0 then | |
87 | mon.setCursorPos(2,5) | |
88 | mon.write("UU-Matter/m: "..fN4 .." ") | |
89 | else | |
90 | mon.setCursorPos(2,5) | |
91 | mon.write("UU-Matter/m: 0 ") | |
92 | end | |
93 | if calc2 >= 0 then | |
94 | mon.setCursorPos(2,6) | |
95 | mon.write("UU-Matter/h: "..fN5 .." ") | |
96 | else | |
97 | mon.setCursorPos(2,6) | |
98 | mon.write("UU-Matter/h: 0 ") | |
99 | end | |
100 | mon.setCursorPos(2,10) | |
101 | mon.write("UU on stock: "..fN6 .." ") | |
102 | else | |
103 | print("Error(1)") | |
104 | end | |
105 | elseif k.Name == "High Voltage Solar Array" then | |
106 | if state == true then | |
107 | hv = k.Size | |
108 | print("HV IstWert: "..hv) | |
109 | ||
110 | fN7 = formatNumber(hv) | |
111 | ||
112 | mon.setCursorPos(2,9) | |
113 | mon.write("HVs on stock: "..fN7 .." ") | |
114 | end | |
115 | end | |
116 | end | |
117 | if state == true then | |
118 | state = false | |
119 | for i = 20,11,-1 do | |
120 | mon.setTextColor(colors.lightGray) | |
121 | if i <= 9 then | |
122 | mon.setCursorPos(18,12) | |
123 | mon.write("reboot in: "..i) | |
124 | end | |
125 | mon.setCursorPos(17,12) | |
126 | mon.write("reboot in: "..i) | |
127 | sleep(1) | |
128 | end | |
129 | print(" ") | |
130 | print("Neue Berechnung gestartet:") | |
131 | else | |
132 | state = true | |
133 | for i = 10,1,-1 do | |
134 | mon.setTextColor(colors.lightGray) | |
135 | if i <= 9 then | |
136 | mon.setCursorPos(18,12) | |
137 | mon.write("reboot in: "..i) | |
138 | end | |
139 | mon.setCursorPos(17,12) | |
140 | mon.write("reboot in: "..i) | |
141 | sleep(1) | |
142 | end | |
143 | end | |
144 | end |