ecco7777

CC Capacitor Bank added View

Sep 4th, 2018
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. function wrapPs(peripheralName)
  2. periTab={}
  3. sideTab={}
  4. if peripheralName==nil then
  5. print("Fehler")
  6. end
  7. local peripherals = peripheral.getNames()
  8. local i2 = 1
  9. for i =1, #peripherals do
  10. if peripheral.getType(peripherals[i])==peripheralName then
  11. periTab[i2]=peripheral.wrap(peripherals[i])
  12. sideTab[i2]=peripherals[i]
  13. i2=i2+1
  14. end
  15. end
  16. if periTab~={} then
  17. return periTab,sideTab
  18. else
  19. return nil
  20. end
  21. end
  22.  
  23. delay=1
  24. e=wrapPs("tile_blockcapacitorbank_name")
  25. m,mSide=wrapPs("monitor")
  26. xMax,yMax=m[1].getSize()
  27.  
  28. while true do
  29. charge=0
  30. maxCharge=0
  31. for i=1,#e do
  32. charge=charge+e[i].getEnergyStored()
  33. maxCharge=maxCharge+e[i].getMaxEnergyStored()
  34. end
  35.  
  36. fp=fs.open("screen","w")
  37. fp.write("term.setBackgroundColor(colors.black) term.clear() term.setBackgroundColor(colors.green) paintutils.drawFilledBox(1,1,"..xMax/maxCharge*charge..","..yMax..")")
  38. fp.close()
  39. shell.run("monitor "..mSide[1].." screen")
  40. term.clear()
  41. sleep(delay)
  42. end
Add Comment
Please, Sign In to add comment