computercam

CC_Domain_Client

Feb 29th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.05 KB | None | 0 0
  1. n = peripheral.wrap("top")
  2. rednet.open("top")
  3. serverID = 0
  4. cdtServer = 2
  5. os.loadAPI("APIs/server")
  6. --END FUNCTIONS
  7. server.TestConnection("true")
  8. shell.run("clear")
  9. write("Username: ")
  10. connectionName = io.read()
  11. write("Password: ")
  12. connectionPassword = io.read()
  13. shell.run("clear")
  14. print("Logging in.")
  15. server.connect(connectionName, connectionPassword)
  16. print("Hey, ", connectionName)
  17. local senderID, message, distance = rednet.receive()
  18. if message == "login" then
  19.     function running()
  20.         write("Command: ")
  21.         command = io.read()
  22.         if command == "kill-server" then
  23.             write("Are you sure you want to kill the server?: [y/n] ")
  24.             answer = io.read()
  25.             if answer == "y" then
  26.                 print("Sending command.")
  27.                 rednet.send(serverID, "kill")
  28.             end
  29.         else
  30.             if command == "chat" then
  31.                 print("Let's go...")
  32.                 shell.run("domain-chat")
  33.             else
  34.                 if command == "msgb" then
  35.                     rednet.send(serverID, "sendToMon")
  36.                     local senderID, message, distance = rednet.receive()
  37.                     write("Display ID: ")
  38.                     displayID = tonumber(io.read())
  39.                     rednet.send(serverID, displayID)
  40.                     write("Message: ")
  41.                     local msg = io.read()
  42.                     print("Sending")
  43.                     rednet.send(serverID, msg)
  44.                     running()
  45.  
  46.                 else
  47.                         if command == "cdt" then
  48.                             rednet.send(cdtServer, "cdt-start")
  49.                             local senderID, message, distance = rednet.receive(5)
  50.                             if message == "start" then
  51.                                 print("Select an OS from the ones below:")
  52.                                 print("1. Recovery mode")
  53.                                 option = io.read()
  54.                                 if option == "1" then
  55.                                     print("Starting File Transfer...")
  56.                                     rednet.send(cdtServer, "cdt-iso-1")
  57.                                 end
  58.                             else
  59.                                 print("CDT Server not online/avaliable")
  60.                                 running()
  61.                             end
  62.                         else
  63.                             if command == "lua" then
  64.                                 shell.run("lua")
  65.                                 running()
  66.                             else
  67.                                 server.disconnect()
  68.                             end
  69.                         end
  70.                         end
  71.                     end
  72.                 end
  73.             end
  74.     running()
  75. else
  76.     print("Sorry, The server returned: ",message, " Sounds like something is wrong, maybe incorrect username or password?")
  77. end
Add Comment
Please, Sign In to add comment