Advertisement
robbim97

ComputerMFSU

Sep 28th, 2019
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local function findPeripheral(_type)
  2.   for _,name in pairs(peripheral.getNames()) do
  3.     if peripheral.getType(name) == _type then
  4.       return peripheral.wrap(name)
  5.     end
  6.   end
  7. end
  8.  
  9. local m = peripheral.wrap("monitor_1")
  10. local mfsu_0 = peripheral.wrap("mfsu_0")
  11. local mfsu_1 = peripheral.wrap("bottom")
  12.  
  13. m.setTextScale(0.5)
  14.  
  15. local total = mfsu_0.getEUCapacity() + mfsu_1.getEUCapacity()
  16. local startRow = 0
  17. local lastCycle = total
  18.  
  19. os.startTimer(1)
  20.  
  21. while true do
  22.  
  23.   local secUntilNight = 0
  24.   local tickTime = (os.time() - 6) * 1000
  25.   if tickTime < 0 then
  26.     tickTime = tickTime + 24000
  27.   end
  28.   local chargeState = false
  29.  
  30.   local stored = mfsu_0.getEUStored() + mfsu_1.getEUStored()
  31.  
  32.   if stored > lastCycle then
  33.     chargeState = true
  34.   end
  35.  
  36.   lastCycle = stored
  37.  
  38.   m.clear()
  39.   m.setBackgroundColor(colors.black)
  40.   m.setTextColor(colors.white)
  41.  
  42.   m.setCursorPos(4, startRow + 1)
  43.   m.write("Gesamt:")
  44.   m.setCursorPos(3, startRow + 2)
  45.   m.setTextColor(colors.lightBlue)
  46.   m.write(tostring(total) .. " EU")
  47.  
  48.   m.setTextColor(colors.white)
  49.  
  50.   m.setCursorPos(4, startRow + 4)
  51.   m.write("Geladen:")
  52.  
  53.   if chargeState then
  54.     m.setTextColor(colors.green)    
  55.   else
  56.     m.setTextColor(colors.red)
  57.   end
  58.  
  59.   m.setCursorPos(3, startRow + 5)
  60.   m.write(tostring(stored) .. " EU")
  61.   m.setCursorPos(3, startRow + 6)
  62.   m.write(tostring((stored/total)*100) .. " %")  
  63.  
  64.   m.setTextColor(colors.white)
  65.  
  66.   m.setCursorPos(4, startRow + 8)
  67.   m.write(textutils.formatTime(os.time(),true) .. " Uhr")
  68.  
  69.   m.setCursorPos(2, startRow + 9)
  70.   if tickTime > 23458 or tickTime < 12541 then
  71.     m.setTextColor(colors.yellow)
  72.     m.write(" Es ist Tag! ")
  73.     m.setCursorPos(2, startRow + 10)
  74.     m.setTextColor(colors.blue)
  75.     if tickTime > 23458 then
  76.       secUntilNight = 36541 - tickTime
  77.     elseif tickTime < 12541 then
  78.       secUntilNight = 12541 - tickTime
  79.     end
  80.     m.write("Nacht in " .. textutils.formatTime(secUntilNight / 1000 ,true))
  81.   else
  82.     m.setTextColor(colors.blue)
  83.     m.write("Schlafenszeit!")
  84.   end
  85.  
  86.   os.pullEvent("timer")
  87.   os.startTimer(1)
  88.  
  89. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement