Advertisement
Tatantyler

CC Uni. LessonServ

Jan 2nd, 2013
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.54 KB | None | 0 0
  1. local lessonDir == "lessons/"
  2. for i,v in ipairs(rs.getSides()) do
  3.     if peripheral.getType(v) == "modem" then
  4.         rednet.open(v)
  5.     end
  6. end
  7.  
  8. while true do
  9.     local id, msg = rednet.receive()
  10.     msg = textutils.unserialize(msg)
  11.     if msg then
  12.         if msg[1] == "lessonServ" then
  13.             if msg[2] == "get_lesson" then
  14.                 if fs.exists(lessonDir..msg[3]) then
  15.                     local fHandle = fs.open(lessonDir..msg[3], "r")
  16.                     rednet.send(id, textutils.serialize({"lessonServ", "lesson_text", fHandle.readAll()}))
  17.                     fHandle.close()
  18.                 end
  19.             end
  20.         end
  21.     end
  22. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement