Advertisement
Alexr360

Regular Pulse

Mar 24th, 2024 (edited)
610
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.73 KB | None | 0 0
  1. -- Get the number of pulses from the user
  2. print("Enter the number of pulses:")
  3. local numPulses = tonumber(read())-1
  4.  
  5. -- Validate user input
  6. if numPulses == nil or numPulses <= 0 then
  7.     print("Invalid input. Please enter a positive number.")
  8.     return
  9. end
  10.  
  11. -- Function to emit a redstone pulse
  12. local function emitPulse()
  13.     redstone.setOutput("right", true)
  14.     sleep(0.5) -- Adjust this delay if needed
  15.     redstone.setOutput("right", false)
  16. end
  17.  
  18. -- Loop to emit the specified number of pulses
  19. for i = 1, numPulses do
  20.     emitPulse()
  21.     print("Pulse emitted: " .. i)
  22.     if i < numPulses then
  23.         print("Waiting 4 seconds until the next pulse...")
  24.         sleep(4)
  25.     end
  26. end
  27.  
  28. print("Finished emitting pulses.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement