Posted 27 August 2016 - 08:47 AM
So I'm trying to, ultimately, create a program to have a turtle follow the player (or at the very least, respond to a "Come to me" command) via X,Y,Z coordinates.
(That's gonna take a while, but I'm working on the basics right now)
I'm having issues, however, transmitting x,y,z coordinates over modems.
I have a script on my PDA (works the same on a stationary PC with modem, though) transmitting my GPS coordinates every 2 seconds:
This is the code on the receiving end (Currently a PC with ender modem):
It is currently trying to put the message to numbers (which I suppose makes sense wouldn't work), but again, I've tried everything I could think of to translate it into usable x, y, and z individual variables.
Basically, what (I think) I need to do is get my X,Y,Z coords, send them as a string, and translate them on the other end into usable, seperate x,y,z coordinates.
As a vector, it prints nil, if I translate them into a string, it prints the coordinates with , between, but won't translate to numbers.
Is there a feasible way to do this that I'm just missing?
(That's gonna take a while, but I'm working on the basics right now)
I'm having issues, however, transmitting x,y,z coordinates over modems.
I have a script on my PDA (works the same on a stationary PC with modem, though) transmitting my GPS coordinates every 2 seconds:
while true do
location=vector.new(gps.locate())
peripheral.call("back", "transmit", 3, 1, tostring(location))
print(location)
os.sleep(2)
end
It's a vector right now, but I've tried everything I could think of to get it to send usable information. From what I see, though, only strings can be sent/received, hence the tostring.This is the code on the receiving end (Currently a PC with ender modem):
while true do
local modem = peripheral.wrap("right")
modem.open(3) -- Open channel 3 so that we can listen on it
local event, modemSide, senderChannel,
replyChannel, message, senderDistance = os.pullEvent("modem_message")
location=tonumber(message)
print(location)
end
It is currently trying to put the message to numbers (which I suppose makes sense wouldn't work), but again, I've tried everything I could think of to translate it into usable x, y, and z individual variables.
Basically, what (I think) I need to do is get my X,Y,Z coords, send them as a string, and translate them on the other end into usable, seperate x,y,z coordinates.
As a vector, it prints nil, if I translate them into a string, it prints the coordinates with , between, but won't translate to numbers.
Is there a feasible way to do this that I'm just missing?
Edited on 27 August 2016 - 06:48 AM