Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function clearScreen()
- term.clear()
- term.setCursorPos(1, 1)
- end
- -- Function to check the GPS y-coordinate
- local function checkYCoordinate()
- -- Get the current GPS location
- local x, y, z = gps.locate(2, false)
- -- Check if the GPS location was successfully obtained
- if x and y and z then
- clearScreen()
- -- Check if the y-coordinate is below -55
- if y < -55 then
- print("The y-coordinate is below -55.")
- local modem = peripheral.find("modem") or error("No modem attached", 0)
- modem.open(43) -- Open 43 so we can receive replies
- modem.transmit(92, 43, "Retract")
- return true -- Exit the loop
- else
- print("The y-coordinate is " .. y)
- return false -- Continue the loop
- end
- else
- print("GPS location not found.")
- return false -- Continue the loop
- end
- end
- -- Main loop to continuously check the y-coordinate
- while not checkYCoordinate() do
- os.sleep(1) -- Wait for 1 second before checking again
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement