Advertisement
CdoubleOK

Power Transfer Rate

Apr 30th, 2023 (edited)
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.78 KB | None | 0 0
  1. local monitor = peripheral.find("monitor")
  2. local modem = peripheral.find("modem")
  3. local dec = peripheral.find("energyDetector")
  4.  
  5. term.clear()
  6. monitor.clear()
  7. monitor.setCursorPos(1,1)
  8. term.setCursorPos(1,1)
  9. print("---Output FE/t---")
  10. monitor.write("Output")
  11.  
  12. while rs.getInput("front") == false
  13. do
  14.  
  15.     local rate = dec.getTransferRate()
  16.     local formatted_rate = string.format("%d", rate)
  17.     formatted_rate = formatted_rate:reverse():gsub("(%d%d%d)","%1,")
  18.     formatted_rate = formatted_rate:reverse():gsub("^,", "")
  19.  
  20.     modem.transmit(24,5,formatted_rate)
  21.     term.setCursorPos(5,2)
  22.     monitor.setCursorPos(1,2)
  23.     term.clearLine()
  24.     monitor.clearLine()
  25.     term.setCursorPos(5,2)
  26.     monitor.write(formatted_rate)
  27.     print(formatted_rate)
  28.     sleep(0.25)
  29. end
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement