Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- IFTTT Redstone Alert Script for ComputerCraft
- -- Replace 'your_key' with your IFTTT Webhooks key
- local ifttt_key = "clyIwla8kLX2m7ACadUXM_" -- Replace with your actual key
- local event_name = "redstone_alert" -- The event name you used in IFTTT
- -- The URL to send the request to
- local url = "https://maker.ifttt.com/trigger/" .. event_name .. "/with/key/" .. ifttt_key
- local url = "https://maker.ifttt.com/trigger/redstone_alert/with/key/clyIwla8kLX2m7ACadUXM_"
- -- Function to send the HTTP request to IFTTT
- local function send_alert()
- local response = http.post(url, "")
- if response then
- print("Alert sent successfully.")
- response.close()
- else
- print("Failed to send alert.")
- end
- end
- -- Main loop
- print("Monitoring redstone input...")
- while true do
- -- Sleep until there is a redstone event
- os.pullEvent("redstone")
- -- Check if there is a redstone signal on any side
- for _, side in ipairs(rs.getSides()) do
- if redstone.getInput(side) then
- print("Redstone signal detected on side: " .. side)
- send_alert()
- -- Wait until the signal is removed to prevent multiple alerts
- repeat
- sleep(1)
- until not redstone.getInput(side)
- print("Signal removed. Resuming monitoring...")
- end
- end
- -- Sleep briefly to prevent excessive CPU usage
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment