Jump to content




Lua functions

wireless help lua

2 replies to this topic

#1 ZapComputer

  • Members
  • 5 posts

Posted 23 August 2018 - 12:40 PM

How do I transfer function data from one computer to another

#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 23 August 2018 - 02: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.

#3 Dog

  • Members
  • 1,179 posts
  • LocationEarth orbit

Posted 23 August 2018 - 04: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






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users