Advertisement
BigBlow_

test

Mar 13th, 2025
7
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. -- Startup message
  2. print("Program starting...")
  3. print("Waiting for redstone signal on top to charge the Laser Amplifier")
  4.  
  5. -- Variable to track whether power should be activated or not
  6. local isPowered = false
  7.  
  8. -- Main program loop
  9. while true do
  10. -- Monitor the top face for the redstone signal strength
  11. local signalPower = redstone.getAnalogInput("top") -- Get the signal strength on the top face
  12. print("Signal strength on top: " .. signalPower)
  13.  
  14. if signalPower == 8 then
  15. -- If the signal strength is 8, send a pulse on top to trigger the Laser Amplifier
  16. redstone.setOutput("top", true)
  17. redstone.setOutput("left", true) -- Also emit redstone on the left face
  18. print("Laser Amplifier activated, firing!")
  19. os.sleep(1) -- Wait a bit before turning off power
  20. redstone.setOutput("top", false)
  21. redstone.setOutput("left", false) -- Turn off redstone on the left as well
  22.  
  23. -- Cut power by sending continuous redstone to the right
  24. redstone.setOutput("right", true)
  25. print("Laser Amplifier power cut.")
  26. isPowered = true -- Mark the power as cut
  27. else
  28. os.sleep(0.1) -- Wait a bit before checking again
  29. end
  30.  
  31. -- Check if a signal is received on the front face to restart the program
  32. if redstone.getInput("front") then
  33. print("Signal received on front face. Resetting the power...")
  34. -- Reactivate the power to the Laser Amplifier
  35. if isPowered then
  36. redstone.setOutput("right", false) -- Restore power to the Laser Amplifier
  37. print("Laser Amplifier power restored.")
  38. isPowered = false -- Mark the power as restored
  39. end
  40. -- Continue monitoring the top signal and don't restart the program
  41. os.sleep(0.5) -- Add a small delay before continuing the loop
  42. end
  43. end
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement