This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
treefrog_65's profile picture

[Lua][Error]Trying to send a table

Started by treefrog_65, 21 January 2013 - 10:42 AM
treefrog_65 #1
Posted 21 January 2013 - 11:42 AM
I am trying to send a table using rednet.broadcast(). But when I try to send it i always get the error message "rednet:327: string expected". My code is below.

local title = read()
  title = title..".txt"
  local h = fs.open(title, "r")
  local data = h.readAll()
  local table = {title,data}
  local msg = textutils.serialize(table)
  rednet.open("right")
  rednet.broadcast(msg)
  rednet.close()
Eric #2
Posted 21 January 2013 - 11:53 AM
Did you check rednet line 327? if type( sSide ) ~= "string" then

rednet.close("right")
theoriginalbit #3
Posted 21 January 2013 - 11:56 AM
Also as a side note don't forget to close the file handle.


h.close()
treefrog_65 #4
Posted 21 January 2013 - 12:07 PM
The problem didnt occur anymore as soon as i changed

rednet.close()
to

rednet.close("right")
Thanks for reminding me to close my file handle too.
ChunLing #5
Posted 21 January 2013 - 02:06 PM
You should generally avoid naming variables (even locally) using certain identifiers that are already in use by the system. The identifier table is one such, and a pretty important one at that.