Advertisement
hevohevo

ComputerCraft Tutorial: msg_receiver_test4

Mar 17th, 2014
1,241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- ##############################
  2. -- msg_receiver test4
  3.  
  4. rednet.open("right")
  5.  
  6. function hevo()
  7.   print("hevohevo!")
  8. end
  9.  
  10. while true do
  11.   local sender_id, message, distance = rednet.receive()
  12.  
  13.   local func = loadstring(message)
  14.   setfenv(func, getfenv()) -- change func's environment(_G) to current one.
  15.   local status, err = pcall(func)
  16.  
  17.   if status then -- success
  18.     print("#",sender_id,": ",message)
  19.   else -- wrong string
  20.     print("(error) #",sender_id,": ",message)
  21.   end
  22. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement