Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local vfs_index = {}
- local server = "test-server"
- local server_channel = 9996
- local r_channel = 9997
- dofile("huffman.lua")
- local command = {
- update = "update"
- }
- local modem = peripheral.find("modem")
- modem.open(r_channel)
- function getMessage(msg)
- modem.transmit(server_channel,r_channel,server..string.char(175,175,175)..msg)
- while true do
- local ev,side,c1,c2,msg = os.pullEvent("modem_message")
- if c1 == r_channel and c2 == server_channel then
- if msg:sub(1,#server) == server then
- msg = msg:sub(#server+1)
- if msg:sub(1,3) == string.char(175,175,175) then
- msg = msg:sub(4)
- return msg
- end
- end
- end
- end
- end
- function update()
- local ret = getMessage(command.update)
- local txt = huffman.decode(nil,ret,true)
- vfs_index = textutils.unserialize(txt)
- end
- function getFile(path)
- local ret = getMessage(command.getFile..path)
- local txt = huffman.decode(nil,ret,true)
- return txt
- end
- update()
- return vfs_index
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement