Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- SPDX-FileCopyrightText: 2026 Tomodachi94
- -- SPDX-License-Identifier: MIT
- -- Send a notification using ntfy.sh when a BuildCraft Quarry is no longer active.
- -- To install: Run "pastebin get n2PRwW0E startup", then restart the computer
- if not fs.exists("hook") then
- print("Welcome to the quarrynotifier first-time setup!")
- print("To start: visit https://ntfy.sh")
- print("Either install the mobile app, and/or")
- print("visit https://ntfy.sh/app.")
- print("Make sure to enable or allow notifications!")
- print("Then, create a new topic. https://ntfy.sh/app can generate you one if you click Subscribe.")
- print("Then, subscribe to that link on your phone or computer.")
- print("And finally, give me the link that I should send notifications to:")
- write("> ")
- local ntfyTopic = read()
- local f = fs.open("hook", "w")
- f.write(ntfyTopic)
- f.close()
- print("If you ever lose the ntfy link, type 'edit hook'")
- if not os.computerLabel() then
- os.setComputerLabel("quarrynotifier")
- end
- print("This computer will now remember your link when broken.")
- end
- local f = fs.open("hook", "r")
- local ntfyTopic = f.readLine()
- f.close()
- print("quarrynotifier is finding the quarry...")
- local quarry
- for _,p in pairs(peripheral.getNames()) do
- local attempt = peripheral.wrap(p)
- if type(attempt.isActive) == "function" then
- quarry = attempt
- print("quarrynotifier found a quarry!")
- break
- end
- end
- if not quarry then
- error("quarrynotifier could not find a quarry. The quarry should be placed next to the computer on any side.")
- end
- print("quarrynotifier is waiting for the quarry...")
- while true do
- os.sleep(5)
- if quarry.isActive() == false then
- print("quarrynotifier detected that the quarry is done!")
- local res = http.post(ntfyTopic, "Your quarry is done!")
- print("quarrynotifier sent a message, exiting...")
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment