Advertisement
Alakazard12

Tech Site

Dec 2nd, 2012
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.94 KB | None | 0 0
  1. bef = "www"
  2. site = "test"
  3. ser = "com"
  4. side = "left"
  5. def = ""
  6. web = "print(\"It worked!\")"
  7.  
  8. function clear()
  9.     term.clear()
  10.     term.setCursorPos(1, 1)
  11. end
  12.  
  13. function round(num)
  14.     local ln = num - math.floor(num)
  15.     if num > .5 then
  16.         return math.ceil(num)
  17.     else
  18.         return math.floor(num)
  19.     end
  20. end
  21.  
  22. function cprint(txt, line)
  23.     local x, y = term.getSize()
  24.     term.setCursorPos(round(round(x-#txt)/2), line)
  25.     term.write(txt)
  26. end
  27.  
  28. clear()
  29. cprint("Running webserer for "..bef.."."..site.."."..ser, 1)
  30. rednet.open("left")
  31.  
  32. while true do
  33.     local id, msg = rednet.receive()
  34.     if string.sub(msg, 1, 7) == "BROWSE:" then
  35.         print("Requested: "..id)
  36.         local rst = textutils.unserialize(string.sub(msg, 8))
  37.         print(rst.bef.."."..rest.site.."."..rst.ser)
  38.         if rst.bef == bef or rst.bef == def then
  39.             if rst.site == site and rst.ser == ser then
  40.                 print("New connection: "..id)
  41.                 rednet.send(id, "BROWSE:"..web)
  42.             end
  43.         end
  44.     end
  45. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement