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

Lua functions

Started by ZapComputer, 23 August 2018 - 11:40 AM
ZapComputer #1
Posted 23 August 2018 - 01:40 PM
How do I transfer function data from one computer to another
KingofGamesYami #2
Posted 23 August 2018 - 03:17 PM
As in, send a function for a second computer to execute? You can't* and it's a bad idea. Just transmit a message and have the other computer do something based on the contents of said message.

*unless it satisfies the requirements of string.dump.
Dog #3
Posted 23 August 2018 - 05:18 PM
To clarify KoGY's reply a bit - execute the function on one computer then send the results to the other computer and have the other computer act on the results. It might look something like this…

--# Computer 1 (id 1)
local function doStuff()
  --# do stuff here that produces the result you need
end

rednet.send(2, result) --# send the result to computer id # 2

--# Computer 2 (id 2)
local id, message = rednet.recieve()
if id == 1 then --# if the data is sent from computer id # 1 then do the following...
  --# do stuff with the message which will be the result sent from computer # 1
end