Advertisement
ZNZNCOOP

MSs

Dec 18th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1. rednet.open('top')
  2. adress_list= {10}
  3. function pop(adress,path)
  4.    for i=1,#adress_list do
  5.       if (adress_list[i] == adress) then
  6.          local data= {}
  7.          data[1]= 'pop'
  8.          data[2]= path
  9.          createclaim(adress,data)
  10.          d,stat= receivereply(adress)
  11.          if (stat == true) then
  12.             draw(d)
  13.          end
  14.       end
  15.    end
  16. end
  17.  
  18. function draw(arr)
  19.    for i=1,#arr do
  20.       print(arr[i])
  21.    end
  22. end
  23.  
  24. function createclaim(adress,data)
  25.    local d= {}
  26.    d= textutils.serialize(data)
  27.    rednet.send(adress,d)
  28. end
  29.  
  30. function receivereply(adress)
  31.    while true do
  32.       local data= {}
  33.       id,message= rednet.receive()
  34.       if (id == adress and message ~= nil) then
  35.          data= textutils.unserialize(message)
  36.          if (data[1] == 'true' and data[2] == 'pop') then
  37.             local d= {}
  38.             for i=3,#data do
  39.                d[#d+1]= data[i]
  40.             end
  41.             return d,true
  42.          elseif (data[1] == 'false' and data[2] == 'pop') then
  43.             d= data
  44.             print('path not found')
  45.             return d,false
  46.          end
  47.       end
  48.    end
  49. end
  50.  
  51. while true do
  52.    write('/')
  53.    adr= ''
  54.    adr= read()
  55.    pop(10,adr)  
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement