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

Sending functions over rednet?

Started by Bagoly, 15 August 2016 - 07:40 PM
Bagoly #1
Posted 15 August 2016 - 09:40 PM
What if I want to send over functions like so?

rednet.open("left")

rec = peripheral.wrap("right") –working with big reactros mod

recStat = rec.getActive
recTemp = rec.getFuelTemperature

table = {recStat, recTemp}

message = textutils.serialize(table)
rednet.send(id, message)




To this I get this error:

textutils:166: Cannot serialize type function



Any ideas???
Lyqyd #2
Posted 15 August 2016 - 11:35 PM
This topic was split from here.
Admicos #3
Posted 16 August 2016 - 12:10 AM
recStat = rec.getActive
recTemp = rec.getFuelTemperature

you are missing parantheses "()" in the end of these lines.
Lupus590 #4
Posted 16 August 2016 - 12:23 AM
recStat = rec.getActive
recTemp = rec.getFuelTemperature

you are missing parantheses "()" in the end of these lines.

the title says that the OP wants to send the functions via rednet.

@ OP: it's not possible at present. It's a Lua limitation.
KingofGamesYami #5
Posted 16 August 2016 - 12:29 AM
Correction, you can't send functions with upvalues. Sending something as simple as "return 1 + 1" would work, as you can simply string.dump and loadstring it.

Admicos suggested (rather badly) the correct way of doing things, which is to send the data, not the functions themselves, over rednet.