Colindapieman

Reactor Control

Feb 27th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.16 KB | None | 0 0
  1. R=peripheral.wrap("back")
  2. rednet.open("top")
  3. --B=peripheral.wrap("top")
  4. C=peripheral.wrap("tile_enderio_blockcapacitorbank_name_0")
  5. mon=peripheral.wrap("right")
  6. function getStorage()
  7. RFcur=(C.getEnergyStored("top")+R.getEnergyStored())
  8. RFmax=(C.getMaxEnergyStored("top")+10000000)
  9. end
  10. mon.clear()
  11. while true do
  12. getStorage()
  13. mon.setCursorPos(1,1)
  14. mon.setTextScale(1.25)
  15. mon.write("Current storage:")
  16. mon.setCursorPos(1,2)
  17. mon.write(math.floor(RFcur/1000)
  18. .."kRF/"
  19. ..math.floor(RFmax/1000)
  20. .."kRF\t\t\t\t\t")
  21. sleep(1)
  22. getStorage()
  23. RF1=RFcur
  24. sleep(2)
  25. getStorage()
  26. RF2=RFcur
  27. RFT=math.floor((RF1-RF2)/40)
  28. mon.setCursorPos(1,4)
  29. mon.write(RFT.."RF/t \t\t\t\t")
  30. mon.setCursorPos(1,5)
  31. tLeft= RFcur/RFT/20/60
  32. if tLeft > 0 then
  33. mon.write("Power for "..math.floor(tLeft).."M")
  34. else
  35. mon.write("Fill in"..floor(RFmax/-RFT/20/60))
  36. end
  37. if RFcur/RFmax < .5 then
  38. R.setActive(true)
  39. end
  40. if RFcur/RFmax > .95 then
  41. R.setActive(false)
  42. end
  43. mon.setCursorPos(1,7)
  44. mon.write(math.floor(RFcur/RFmax*100)
  45. .."% full.")
  46. mon.setCursorPos(1,8)
  47. if R.getActive()==false then
  48. mon.write("Reactor off.")
  49. end
  50. if R.getActive()==true then
  51. mon.write("Reactor on. ")
  52. end
  53. end
Advertisement
Add Comment
Please, Sign In to add comment