Posted 24 June 2014 - 02:38 AM
as I was writing a new turtle program I also decided to write a helper for sending rednet messages. I use the command sendMsg(id,reply,data1,data2,data3,data4,data5,data6) (line 121) it turns all that and then a bit more into a table and then sends the table over standard rednet.
however I am hitting a snag, I am trying to put string "co" in data1 area but then its trying to concatenate and failing.(at least that's what I am thinking its doing)
I came to this conclusion after just getting error "textutils:177: attempt to concatenate string and nil" so I added print numbers to watch where it was failing. its failing after print("11") which would be line 197.
any ideas on how to stop it from concat or is it something I am not seeing?
pastebin link to full code, http://pastebin.com/NJJuvzHZ
code snippets though they do not like my formatting.
if dataTable["wireless"] then
print("11")
sendMsg(0,true,co,0,0,0,0,0) <—- where I think the issue is
print("12")
if recTable[3] == "yes" then
dataTable["co"] = true
dataTable["coID"] = recTable("sid")
dataTable["yTravel"] = recTable[4]
updateConfig()
else
end
end
– rednet functions
function sendMsg(rid,reply,data1,data2,data3,data4,data5,data6)
sendTable = {}
sendTable[1] = rid
sendTable[2] = reply
sendTable[3] = data1
sendTable[4] = data2
sendTable[5] = data3
sendTable[6] = data4
sendTable[7] = data5
sendTable[8] = data6
sendTable["sid"] = os.getComputerID()
sendTable["name"] = os.getComputerLabel()
sendTable["status"] = status
transmitData(sendTable)
end
function transmitData(data)
if dataTable["wireless"] then
if data[1] == 0 then
rednet.broadcast(textutils.serialize(sendTable))
else
rednet.send(data[1],textutils.serialize(sendTable))
end
end
if data[2] then
getMsg()
end
end
function getMsg()
if dataTable["wireless"] then
recTable = {}
sid, msg, d = rednet.receive(3)
recTable = textutils.unserialize(msg)
end
end
however I am hitting a snag, I am trying to put string "co" in data1 area but then its trying to concatenate and failing.(at least that's what I am thinking its doing)
I came to this conclusion after just getting error "textutils:177: attempt to concatenate string and nil" so I added print numbers to watch where it was failing. its failing after print("11") which would be line 197.
any ideas on how to stop it from concat or is it something I am not seeing?
pastebin link to full code, http://pastebin.com/NJJuvzHZ
code snippets though they do not like my formatting.
Spoiler
–co checkif dataTable["wireless"] then
print("11")
sendMsg(0,true,co,0,0,0,0,0) <—- where I think the issue is
print("12")
if recTable[3] == "yes" then
dataTable["co"] = true
dataTable["coID"] = recTable("sid")
dataTable["yTravel"] = recTable[4]
updateConfig()
else
end
end
– rednet functions
function sendMsg(rid,reply,data1,data2,data3,data4,data5,data6)
sendTable = {}
sendTable[1] = rid
sendTable[2] = reply
sendTable[3] = data1
sendTable[4] = data2
sendTable[5] = data3
sendTable[6] = data4
sendTable[7] = data5
sendTable[8] = data6
sendTable["sid"] = os.getComputerID()
sendTable["name"] = os.getComputerLabel()
sendTable["status"] = status
transmitData(sendTable)
end
function transmitData(data)
if dataTable["wireless"] then
if data[1] == 0 then
rednet.broadcast(textutils.serialize(sendTable))
else
rednet.send(data[1],textutils.serialize(sendTable))
end
end
if data[2] then
getMsg()
end
end
function getMsg()
if dataTable["wireless"] then
recTable = {}
sid, msg, d = rednet.receive(3)
recTable = textutils.unserialize(msg)
end
end