Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ocs/apis/sensor")
- sen = sensor.wrap("bottom")
- mon = peripheral.wrap("left")
- state = false
- mon.setTextScale(1)
- mon.clear()
- function formatNumber(number)
- local formatted = tostring(number)
- local k = #formatted % 3
- if k == 0 then k = 3 end
- local result = formatted:sub(1, k)
- while k < #formatted do
- result = result .. "." .. formatted:sub(k + 1, k + 3)
- k = k + 3
- end
- return result
- end
- while true do
- s = sen.getTargets()
- function getS()
- for v, k in pairs(s) do
- if k.Name == "ME Wireless Access Point" then
- target = v
- end
- end
- return target
- end
- f = getS()
- s1 = sen.getTargetDetails(target)
- for v, k in pairs(s1.Items) do
- mon.setTextColor(colors.yellow)
- if k.Name == "Low Voltage Solar Array" then
- if state == false then
- lv1 = k.Size
- print("LV Rechenwert 1: "..lv1)
- elseif state == true then
- lv2 = k.Size
- print("LV IstWert 2: "..lv2)
- calc = (lv2 - lv1) * 6 --LVs pro Minute
- calc2 = calc * 60 --LVs pro Stunde
- fN1 = formatNumber(calc)
- fN2 = formatNumber(calc2)
- fN3 = formatNumber(lv2)
- if calc >= 0 then
- mon.setCursorPos(2,2)
- mon.write("LV Solars/m: "..fN1 .." ")
- else
- mon.setCursorPos(2,2)
- mon.write("LV Solars/m: 0 ")
- end
- if calc2 >= 0 then
- mon.setCursorPos(2,3)
- mon.write("LV Solars/h: "..fN2 .." ")
- else
- mon.setCursorPos(2,3)
- mon.write("LV Solars/h: 0 ")
- end
- mon.setCursorPos(2,8)
- mon.write("LVs on stock: "..fN3 .." ")
- else
- print("Error(1)")
- end
- elseif k.Name == "UU-Matter" then
- if state == false then
- uu1 = k.Size
- print("UU Rechenwert 1: "..uu1)
- elseif state == true then
- uu2 = k.Size
- print("UU IstWert 2: "..uu2)
- calc = (uu2 - uu1) * 6
- calc2 = calc * 60
- fN4 = formatNumber(calc)
- fN5 = formatNumber(calc2)
- fN6 = formatNumber(uu2)
- if calc >= 0 then
- mon.setCursorPos(2,5)
- mon.write("UU-Matter/m: "..fN4 .." ")
- else
- mon.setCursorPos(2,5)
- mon.write("UU-Matter/m: 0 ")
- end
- if calc2 >= 0 then
- mon.setCursorPos(2,6)
- mon.write("UU-Matter/h: "..fN5 .." ")
- else
- mon.setCursorPos(2,6)
- mon.write("UU-Matter/h: 0 ")
- end
- mon.setCursorPos(2,10)
- mon.write("UU on stock: "..fN6 .." ")
- else
- print("Error(1)")
- end
- elseif k.Name == "High Voltage Solar Array" then
- if state == true then
- hv = k.Size
- print("HV IstWert: "..hv)
- fN7 = formatNumber(hv)
- mon.setCursorPos(2,9)
- mon.write("HVs on stock: "..fN7 .." ")
- end
- end
- end
- if state == true then
- state = false
- for i = 20,11,-1 do
- mon.setTextColor(colors.lightGray)
- if i <= 9 then
- mon.setCursorPos(18,12)
- mon.write("reboot in: "..i)
- end
- mon.setCursorPos(17,12)
- mon.write("reboot in: "..i)
- sleep(1)
- end
- print(" ")
- print("Neue Berechnung gestartet:")
- else
- state = true
- for i = 10,1,-1 do
- mon.setTextColor(colors.lightGray)
- if i <= 9 then
- mon.setCursorPos(18,12)
- mon.write("reboot in: "..i)
- end
- mon.setCursorPos(17,12)
- mon.write("reboot in: "..i)
- sleep(1)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement