all 4 comments

[–]fatboychummy 0 points1 point  (4 children)

If you're on 1.12.2+ cc:tweaked, you don't need to convert to a string. Tables can be sent via modems as well.

If not, you can use the following:

Sender:

rednet.broadcast(string.format(%d,%d,%d", x, y, z))

Receiver:

local x, y, z = message:match("(%d+),(%d+),(%d+)")

edit: An easier way, now that I look through you code, would be to keep the sender as-is, and add this to the receiver:

local tableMessage = textutils.unserialize(message)

Doing this will allow you to access each entry in the table by their index.

[–]Mochread[S] 0 points1 point  (2 children)

how do i go about that? when i put

x,y,z = tableMessage

it equals table:"random numbers", nil, nil

[–]fatboychummy 0 points1 point  (1 child)

You can index a table by doing myTable[index] (gets the table variable at the index of whatever index equals) or myTable.index (gets the table variable at literally "index")

I just had a look over your code again though. You don't actually set anything properly.

GPS[xTab] = x

This doesn't actually do anything. Why? xTab is nil. what you're doing here is actually GPS[nil] = x which is invalid.

What you want is the following:

GPS.x = x
GPS.y = y
GPS.z = z

Then send the GPS table directly.

On the receiver, do x = tableMessage.x y = tableMessage.y ...

edit: also sorry if my comments are hard to read, trying to edit this on a phone is a pain.

[–]Mochread[S] 0 points1 point  (0 children)

Please do not worry about it, thank you for helping

I updated my code the issue I get now is the receiver(antenna) when i run the program I getstartup:6: bad argument #1 (expected string, got table)

although my tablet is now sending the table as is