Advertisement
susautwcraft

凜的1.7.10#12-control the reactor

Oct 10th, 2015
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. while true do //無窮迴圈
  2. local reactor=peripheral.wrap("back") //因是包裝外部數據(就是computer後面的Reactor Computer Port給的資料)
  3. local allstore=10000000 //最高暫存電量
  4. local now=reactor.getEnergyStored() //現在的暫存電量
  5. if now/allstore*100>80 then //當現在的暫存電量佔最高暫存電量大於80%為真時
  6. reactor.setActive(false) //關閉reactor
  7. else //否則
  8. reactor.setActive(true) //開啟reactor
  9. end //結束判斷
  10. print("-------------------------") /分隔線
  11. print(now,"(use:",now/allstore*100,"%)")
  12. if reactor.getActive() then //判斷狀態(影片中未出現)
  13. print("charging")
  14. else
  15. print("discharging")
  16. end
  17. sleep(10) //休息10秒
  18. end //結束迴圈
  19.  
  20.  
  21. -------------------------------------------------------
  22. 上面的程式中//後面的是註解(不要打到程式裡面)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement