{
"smigger22",
"jasperdekiller",
}
I have no code cos its midnight
tables help
Started by _removed, Feb 13 2015 11:43 PM
6 replies to this topic
#1
Posted 13 February 2015 - 11:43 PM
I have a computer sending stuff through rednet. It is in a table and I dont know to make it print all values. This is an example of what it would be sending.
#2
Posted 14 February 2015 - 12:19 AM
You need to loop through the table.
smigger22
jasperdekiller
if type(message) == "table" then for a,v in pairs(message) do print(v) end endThis would print out, for your table
smigger22
jasperdekiller
Edited by Dragon53535, 14 February 2015 - 12:20 AM.
#3
Posted 14 February 2015 - 09:13 AM
Dragon53535, on 14 February 2015 - 12:19 AM, said:
You need to loop through the table.
smigger22
jasperdekiller
if type(message) == "table" then for k,v in pairs(message) do print(v) end endThis would print out, for your table
smigger22
jasperdekiller
#4
Posted 14 February 2015 - 10:24 AM
Then post your code so that I can point out your error.
#5
Posted 15 February 2015 - 11:35 PM
I already know your error.

When you send your message, instead of sending the table, send this:
textutils.serialize(table)
Then when receiving it, do:
table=textutils.unserialize(table)
To explain this, you can only send strings over rednet. Serializing converts a table into a string, and unserializing converts a serialized table(string) into a table.
You CANNOT, however, send functions over rednet.

When you send your message, instead of sending the table, send this:
textutils.serialize(table)
Then when receiving it, do:
table=textutils.unserialize(table)
To explain this, you can only send strings over rednet. Serializing converts a table into a string, and unserializing converts a serialized table(string) into a table.
You CANNOT, however, send functions over rednet.
Edited by Geforce Fan, 15 February 2015 - 11:38 PM.
#7
Posted 16 February 2015 - 01:24 AM
It depends on which version of ComputerCraft you're using. Anything even half recent will indeed handle it for you.
smigger22 could be trying to capture the rednet_message event, or making a number of other mistakes. Can't really say for sure without seeing the code.
smigger22 could be trying to capture the rednet_message event, or making a number of other mistakes. Can't really say for sure without seeing the code.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











