Jump to content




Sending Tables?


  • You cannot reply to this topic
3 replies to this topic

#1 martin509

  • Members
  • 53 posts

Posted 26 March 2013 - 09:58 AM

I'm trying to send a table over rednet then have a variable changed to one of the table's values.
Here's my code:
--Sender Code
local rednetoutputs = { up = 0, down = 0, diffselected}
rednet.open("bottom")
--unrelated code
diff = io.read()
if diff == "5" then gDiff = 500
rednetoutputs.diffselected = "5"
rednet.send(26, textutils.serialize(rednetoutputs))
end
--Receiver Code
rednet.open("bottom")
os.pullEvent("rednet_message")
local id1, difftable, dist1 = rednet.receive()
textutils.unserialize(difftable)
diff = rednetoutputs[diffselected]
if diff == "5" then gDiff = 500
I'm working off of Casper's Pong as a code base.

#2 Viproz

  • Members
  • 58 posts

Posted 26 March 2013 - 10:21 AM

rednetoutputs.diffselecteddiff = 5 
rednetoutputs[diffselected]
 
Maybe you just Forget rednetoutput. ?

#3 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 26 March 2013 - 10:34 AM

remove 'os.pullEvent("rednet_message")'

And when you use textutils.unserialize, you're not giving it a variable, do this:
difftable = textutils.unserialize(difftable)

Not sure what you're trying to do here :?

#4 martin509

  • Members
  • 53 posts

Posted 27 March 2013 - 01:19 AM

Thanks, I'll try that out.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users