RavenSH4

PowerControl

Jul 3rd, 2024
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. --read analog signal and output power signal
  2. rs_in_side = "back"
  3. rs_out_side = "left"
  4. inputRedstoneLevel = 15
  5. isPowerOutput = false
  6.  
  7. --update data from redstone channels (sensors)
  8. function UpdateSensors()
  9. inputRedstoneLevel = rs.getInput(rs_in_side)
  10.  
  11. if (isPowerOutput == false and inputRedstoneLevel < 5) then
  12. isPowerOutput = true
  13. end
  14. if (isPowerOutput == true and inputRedstoneLevel > 13) then
  15. isPowerOutput = false
  16. end
  17.  
  18. if isPowerOutput then
  19. rs.setOutput(rs_out_side, true)
  20. else
  21. rs.setOutput(rs_out_side, false)
  22. end
  23. end
  24.  
  25. UpdateSensors()
  26.  
  27. repeat
  28. event,p1,p2,p3 = os.pullEvent()
  29. if event=="redstone" then
  30. UpdateSensors()
  31. end
  32. until event=="char" and p1==("q")
Add Comment
Please, Sign In to add comment