can you send an array over rednet? if not can i some how send one as a string.
[Lua][Question] arrays over rednet
Started by maddigger00009, Sep 30 2012 03:10 PM
3 replies to this topic
#1
Posted 30 September 2012 - 03:10 PM
#2
Posted 30 September 2012 - 03:19 PM
You can convert a table to a string using textutils.serialize( table )
#3
Posted 30 September 2012 - 03:21 PM
If you send the words separated by a space you could do
local array = {}
local id, message = rednet.receive()
for word in string.gmatch(message, "%a+") do
table.insert(array, word)
end
#4
Posted 30 September 2012 - 03:28 PM
inventor2514, on 30 September 2012 - 03:19 PM, said:
You can convert a table to a string using textutils.serialize( table )
local array = {
"chicken",
"car",
"craftComputer"
}
local sendString = ""
for _, value in pairs(array) do
sendString = sendString + " " + value
end
string.sub(sendString, 2) -- This just removes the first 'space'
rednet.send(compId, sendString)
-- This will send:
-- chicken car craftComputer
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











