Advertisement
amr2003

SERVER_CWC_LUALAND_MC_SERVER ver: 9.0

Feb 15th, 2015
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.02 KB | None | 0 0
  1. -- Made by Sapphire Tech
  2. --PLEASE DO NOT EDIT!
  3. local version = "9.1"
  4. local not_found = "term.setBackgroundColor(colors.white) term.setTextColor(colors.lightGray) term.clear() term.setCursorPos(1,1) print('Uh oh, captin, were lost!') print('The file was not found on the server!')"
  5. local sides = {
  6.     "top",
  7.     "bottom",
  8.     "back",
  9.     "left",
  10.     "right"
  11. }
  12. term.setBackgroundColor(colors.white)
  13. term.setTextColor(colors.lightGray)
  14. if not fs.exists("settings") then
  15.     write("WARN: Enter domain name: ")
  16.     local newd = read()
  17.     local dmn = fs.open("settings","w")
  18.     dmn.write(newd)
  19.     term.clear()
  20.     term.setCursorPos(1,1)
  21. end
  22. if not fs.exists("index") then
  23.     print("WARN: Missing file index!")
  24. term.clear()
  25. term.setCursorPos(1,1)
  26. print("INFO: Server version: "..version)
  27.     for i = 1, #sides do
  28.       if peripheral.isPresent(sides[i]) then
  29.         if peripheral.getType(sides[i]) == "modem" then
  30.           local modem = peripheral.find("modem")
  31.           if modem.isWireless() then
  32.             rednet.open(sides[i])
  33.             print("INFO: Modem found on "..sides[i])
  34.           else
  35.             print("WARN: Modem not found!")
  36.           end
  37.         end
  38.       end
  39.     end
  40. local domainf = fs.open("settings")
  41. local domain = doaminf.readAll()
  42. domainf.close()
  43. print("INFO: Server hosted on "..domain)
  44. while true do
  45.     fm2 = tostring(evnt[2])
  46.     fm3 = tostring(evnt[3])
  47.     if fm2 ~= nil and fm3 ~= nil then
  48.     local evnt = { rednet.receive() }
  49.     if evnt[3] == domain then
  50.         if fs.exists(evnt[2]) then
  51.             local codef = fs.open(evnt[2])
  52.             local code = codef.readAll()
  53.             codef.close()
  54.             rednet.send(evnt[1],code)
  55.             print("INFO: The computer at "..evnt[1].." has requested the page "..evnt[2].." the page has been sent!")
  56.         else
  57.             rednet.send(evnt[1],not_found)
  58.             print("INFO: The computer at "..evnt[1].." has requested the page "..evnt[2].." the page has not been sent!")
  59.         end
  60.     end
  61.  sleep(0)
  62. end
  63. end
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement