-- Location Broadcaster Script -- This script gets your GPS position and broadcasts it over a modem -- Find and wrap the modem peripheral local modem = peripheral.find("modem") if not modem then error("No modem found! Please attach a wireless modem.") end -- Open a channel for broadcasting (channel 1 in this case) -- The turtle listening must also be on channel 1 modem. open(1) print("Location Broadcaster Started") print("Broadcasting on channel 1...") print("Press Ctrl+T to stop") -- Main loop - broadcasts position every 2 seconds while true do -- Get current GPS coordinates -- Requires GPS satellites to be set up in your world local x, y, z = gps. locate(5) -- 5 second timeout if x then -- Successfully got position print(string.format("Position: X=%.1f, Y=%.1f, Z=%.1f", x, y, z)) -- Broadcast the coordinates as a table -- Channel 1 = broadcast channel -- Channel 1 = reply channel (not used here, but required) modem.transmit(1, 1, {x = x, y = y, z = z}) print("Broadcasted position!") else -- GPS lookup failed print("Unable to get GPS position. Are GPS satellites set up?") end -- Wait 2 seconds before next broadcast sleep(2) end