Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function findPeripheral(_type)
- for _,name in pairs(peripheral.getNames()) do
- if peripheral.getType(name) == _type then
- return peripheral.wrap(name)
- end
- end
- end
- local m = peripheral.wrap("monitor_1")
- local mfsu_0 = peripheral.wrap("mfsu_0")
- local mfsu_1 = peripheral.wrap("bottom")
- m.setTextScale(0.5)
- local total = mfsu_0.getEUCapacity() + mfsu_1.getEUCapacity()
- local startRow = 0
- local lastCycle = total
- os.startTimer(1)
- while true do
- local secUntilNight = 0
- local tickTime = (os.time() - 6) * 1000
- if tickTime < 0 then
- tickTime = tickTime + 24000
- end
- local chargeState = false
- local stored = mfsu_0.getEUStored() + mfsu_1.getEUStored()
- if stored > lastCycle then
- chargeState = true
- end
- lastCycle = stored
- m.clear()
- m.setBackgroundColor(colors.black)
- m.setTextColor(colors.white)
- m.setCursorPos(4, startRow + 1)
- m.write("Gesamt:")
- m.setCursorPos(3, startRow + 2)
- m.setTextColor(colors.lightBlue)
- m.write(tostring(total) .. " EU")
- m.setTextColor(colors.white)
- m.setCursorPos(4, startRow + 4)
- m.write("Geladen:")
- if chargeState then
- m.setTextColor(colors.green)
- else
- m.setTextColor(colors.red)
- end
- m.setCursorPos(3, startRow + 5)
- m.write(tostring(stored) .. " EU")
- m.setCursorPos(3, startRow + 6)
- m.write(tostring((stored/total)*100) .. " %")
- m.setTextColor(colors.white)
- m.setCursorPos(4, startRow + 8)
- m.write(textutils.formatTime(os.time(),true) .. " Uhr")
- m.setCursorPos(2, startRow + 9)
- if tickTime > 23458 or tickTime < 12541 then
- m.setTextColor(colors.yellow)
- m.write(" Es ist Tag! ")
- m.setCursorPos(2, startRow + 10)
- m.setTextColor(colors.blue)
- if tickTime > 23458 then
- secUntilNight = 36541 - tickTime
- elseif tickTime < 12541 then
- secUntilNight = 12541 - tickTime
- end
- m.write("Nacht in " .. textutils.formatTime(secUntilNight / 1000 ,true))
- else
- m.setTextColor(colors.blue)
- m.write("Schlafenszeit!")
- end
- os.pullEvent("timer")
- os.startTimer(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement