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

Sending Tables?

Started by martin509, 26 March 2013 - 08:58 AM
martin509 #1
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.
Viproz #2
Posted 26 March 2013 - 10:21 AM
rednetoutputs.diffselecteddiff = 5 
rednetoutputs[diffselected]
 
Maybe you just Forget rednetoutput. ?
remiX #3
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 :?
martin509 #4
Posted 27 March 2013 - 01:19 AM
Thanks, I'll try that out.