Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Startup message
- print("Program starting...")
- print("Waiting for redstone signal on top to charge the Laser Amplifier")
- -- Variable to track whether power should be activated or not
- local isPowered = false
- -- Main program loop
- while true do
- -- Monitor the top face for the redstone signal strength
- local signalPower = redstone.getAnalogInput("top") -- Get the signal strength on the top face
- print("Signal strength on top: " .. signalPower)
- if signalPower == 8 then
- -- If the signal strength is 8, send a pulse on top to trigger the Laser Amplifier
- redstone.setOutput("top", true)
- redstone.setOutput("left", true) -- Also emit redstone on the left face
- print("Laser Amplifier activated, firing!")
- os.sleep(1) -- Wait a bit before turning off power
- redstone.setOutput("top", false)
- redstone.setOutput("left", false) -- Turn off redstone on the left as well
- -- Cut power by sending continuous redstone to the right
- redstone.setOutput("right", true)
- print("Laser Amplifier power cut.")
- isPowered = true -- Mark the power as cut
- else
- os.sleep(0.1) -- Wait a bit before checking again
- end
- -- Check if a signal is received on the front face to restart the program
- if redstone.getInput("front") then
- print("Signal received on front face. Resetting the power...")
- -- Reactivate the power to the Laser Amplifier
- if isPowered then
- redstone.setOutput("right", false) -- Restore power to the Laser Amplifier
- print("Laser Amplifier power restored.")
- isPowered = false -- Mark the power as restored
- end
- -- Continue monitoring the top signal and don't restart the program
- os.sleep(0.5) -- Add a small delay before continuing the loop
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement