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