This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
How to send GPS coordinates?
Started by Wilma456, 10 June 2016 - 03:58 PMPosted 10 June 2016 - 05:58 PM
How can I send GPS coordinates like the GPS Program?
Posted 10 June 2016 - 06:46 PM
Through the modem api. Your computer needs to know it's position, and when prompted, it should send the coordinates.
local modem = peripheral.wrap(side)
modem.transmit(channel, replyChannel, {x=x,y=y,z=z})
Edited on 11 June 2016 - 10:49 AM
Posted 11 June 2016 - 09:19 AM
Creator, that's not rednet at all, that's the modem api. Which is the correct thing to do, you'd need to use the modem api as that also sends the distance from the server.
I would take a look at the modem api's page.
Like creator did, you need to wrap the modem, and then transmit the message. When receiving you need to pull modem_message events and correctly figure out the block you are currently on by testing the distances versus the coordinates sent and doing some math. I don't know the exact math, but I believe it's either algebra or trig.
Each node needs to know it's actual coordinates however.
If you don't entirely understand, just check out the gps program's source.
I would take a look at the modem api's page.
Like creator did, you need to wrap the modem, and then transmit the message. When receiving you need to pull modem_message events and correctly figure out the block you are currently on by testing the distances versus the coordinates sent and doing some math. I don't know the exact math, but I believe it's either algebra or trig.
Each node needs to know it's actual coordinates however.
If you don't entirely understand, just check out the gps program's source.
Edited on 11 June 2016 - 07:21 AM
Posted 11 June 2016 - 10:40 AM
I know it's not rednet. I just dislike rednet and avoid using it at all costs.
Edited on 11 June 2016 - 10:49 AM
Posted 11 June 2016 - 11:27 AM
You however specifically stated rednet, and then used the modem api. I felt it necessary to point out the fact that the two were different.
Edit: You also misspelled rednet the first time on your last post.
Edit: You also misspelled rednet the first time on your last post.
Edited on 11 June 2016 - 09:27 AM
Posted 11 June 2016 - 12:49 PM
You however specifically stated rednet, and then used the modem api. I felt it necessary to point out the fact that the two were different.
Edit: You also misspelled rednet the first time on your last post.
Yeah, my bad. Just noticed.
Posted 11 June 2016 - 03:58 PM
I have taken code from gps and changed it. Thankyou all.