Advertisement
Alexr360

Miner Remote

Mar 24th, 2024 (edited)
648
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.07 KB | None | 0 0
  1. local function clearScreen()
  2.   term.clear()
  3.   term.setCursorPos(1, 1)
  4. end
  5.  
  6. -- Function to check the GPS y-coordinate
  7. local function checkYCoordinate()
  8.     -- Get the current GPS location
  9.     local x, y, z = gps.locate(2, false)
  10.  
  11.     -- Check if the GPS location was successfully obtained
  12.     if x and y and z then
  13.         clearScreen()
  14.         -- Check if the y-coordinate is below -55
  15.         if y < -55 then
  16.             print("The y-coordinate is below -55.")
  17.  
  18.             local modem = peripheral.find("modem") or error("No modem attached", 0)
  19.             modem.open(43) -- Open 43 so we can receive replies
  20.  
  21.             modem.transmit(92, 43, "Retract")
  22.             return true  -- Exit the loop
  23.         else
  24.             print("The y-coordinate is " .. y)
  25.             return false  -- Continue the loop
  26.         end
  27.     else
  28.         print("GPS location not found.")
  29.         return false  -- Continue the loop
  30.     end
  31. end
  32.  
  33. -- Main loop to continuously check the y-coordinate
  34. while not checkYCoordinate() do
  35.     os.sleep(1)  -- Wait for 1 second before checking again
  36. end
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement