Advertisement
hevohevo

test_msg_receiver

Jun 8th, 2014
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.70 KB | None | 0 0
  1. rednet.open("left")
  2. local sender_id = 17
  3. local my_id = os.getComputerID()
  4. local msg_box = {}
  5.  
  6. function myreceive()
  7.   while true do
  8.     local res = {rednet.receive()}
  9.     rednet.send(17, res[2])
  10.     table.insert(msg_box,res)
  11.   end
  12. end
  13.  
  14. function guruguru()
  15.   local pointer = 0
  16.   while true do
  17. --    print(#msg_box)
  18.     local msg_box_size = #msg_box
  19.     if pointer < msg_box_size then
  20.       for i=pointer+1 , msg_box_size do
  21.         local msg = msg_box[i][2]
  22.         print(i,': ',msg)
  23.         loadstring(msg)()
  24.       end
  25.       pointer = msg_box_size
  26.     end
  27.  
  28.     -- main heavy working
  29.     for i=1,16 do
  30.       turtle.select(i)
  31.     end
  32.   end
  33. end
  34.  
  35. parallel.waitForAll(myreceive, guruguru)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement