Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- GPS Locator Code
- local gpsDataFiles = { "x.data", "y.data", "z.data" }
- -- Function to read GPS data from files
- local function readGPSData()
- local coordinates = {}
- for _, filename in ipairs(gpsDataFiles) do
- if fs.exists(filename) then
- local file = fs.open(filename, "r")
- table.insert(coordinates, tonumber(file.readLine()))
- file.close()
- else
- print("GPS data file " .. filename .. " does not exist.")
- return nil
- end
- end
- return coordinates
- end
- -- Function to display GPS coordinates
- local function displayGPS()
- local coordinates = readGPSData()
- if coordinates then
- print("Current GPS Coordinates: (X: " .. coordinates[1] .. ", Y: " .. coordinates[2] .. ", Z: " .. coordinates[3] .. ")")
- end
- end
- -- Main loop
- while true do
- displayGPS()
- sleep(5) -- Check GPS data every 5 seconds
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement