Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- GPS Satellite Program with Fixed IDs
- -- Define the satellite's Computer ID and coordinates
- local satelliteID = os.getComputerID() -- Automatically get this computer's ID
- local xPos, yPos, zPos = 100, 64, 100 -- Replace with the satellite's coordinates
- -- Open the rednet modem
- local function startGPS()
- rednet.open("right") -- Ensure the modem is on the correct side
- print("Satellite ID " .. satelliteID .. " is broadcasting...")
- while true do
- -- Wait for a request and respond with the satellite's data
- local senderID, message = rednet.receive("GPS")
- if message == "request" then
- local data = {
- id = satelliteID,
- x = xPos,
- y = yPos,
- z = zPos
- }
- rednet.send(senderID, textutils.serializeJSON(data), "GPS")
- print("Sent data to " .. senderID)
- end
- end
- end
- startGPS()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement