Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open('top')
- function reply(adress,data)
- data= textutils.unserialize(data)
- if (data[1] == 'pop') then
- if (fs.exists(data[2]) == true) then
- if (fs.isDir(data[2]) == true) then
- list= fs.list(data[2])
- for i=1,#list do
- if (fs.isDir(data[2]..'/'..list[i]) == true) then
- list[i]= 'Dir:'..list[i]
- end
- end
- datas= createreply(adress,list,'pop','true')
- sleep(1)
- rednet.send(adress,datas)
- else
- datas= createreply(adress,nil,'pop','false')
- sleep(1)
- rednet.send(adress,datas)
- end
- else
- datas= createreply(adress,nil,'pop','false')
- sleep(1)
- rednet.send(adress,datas)
- end
- end
- end
- function draw(arr)
- for i=1,#arr do
- write(arr[i],' ')
- end
- end
- function createreply(adress,data,func,stat)
- local datas= {}
- datas= data
- if (func == 'pop' and stat == 'true') then
- table.insert(datas,1,stat)
- table.insert(datas,2,'pop')
- temp= textutils.serialize(datas)
- return temp
- elseif (func == 'pop' and stat == 'false') then
- datas= {}
- datas[1]= stat
- datas[2]= 'pop'
- temp= textutils.serialize(datas)
- return temp
- end
- end
- args= {...}
- if (args[1] == nil) then error() end
- MAIN_SERBER_ID= args[1]+0
- while true do
- id,message= rednet.receive()
- if (id == MAIN_SERBER_ID) then
- reply(id,message)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement