Advertisement
Guest User

lock

a guest
Jun 21st, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.59 KB | None | 0 0
  1. local oldPull = os.pullEvent;
  2. os.pullEvent = os.pullEventRaw;
  3. whileAsk = true;
  4.  
  5.  
  6. modemSide = "left";
  7. serverId = 11;
  8. doorSide = "right";
  9.  
  10.  
  11. if peripheral.getType(modemSide) == "modem" then
  12.   rednet.open(modemSide);
  13. else
  14.   while whileAsk == true do
  15.     shell.run("clear");
  16.     print("Door offline!");
  17.     print("Connect a Modem on the "..modemSide.." side!");
  18.     sleep(1);
  19.     if peripheral.getType(modemSide) == "modem" then
  20.       whileAsk = false;
  21.       rednet.open(modemSide);
  22.     end;
  23.   end;
  24. end;
  25. whileAsk = true;
  26.  
  27. while whileAsk == true do
  28.   shell.run("clear");
  29.   write("Username: ");
  30.   user = io.read();
  31.   write("Password: ");
  32.   password = io.read();
  33.   rednet.send(serverId, user);
  34.   sleep(0.5);
  35.   rednet.send(serverId, password);
  36.   id, answer = rednet.receive(3);
  37.   shell.run("clear");
  38.   if answer == "" or answer == nil then
  39.     print("No connection to the server!");
  40.   else
  41.     if id == serverId then
  42.       if answer == "nottrusted" then
  43.         print("This door has no trusted connection with the server!");
  44.       end;
  45.       if answer == "unknownuser" then
  46.         print("Unknown user!");
  47.       end;
  48.       if answer == "wrongpassword" then
  49.         print("Wrong password!");
  50.       end;
  51.       if answer == "noperm" then
  52.         print("No permission to this door!");
  53.       end;
  54.       if answer == "true" then
  55.         print("Correct informations.");
  56.         sleep(0.5);
  57.         shell.run("redset "..doorSide.." true");
  58.         sleep(2.5);
  59.         shell.run("redset "..doorSide.." false");
  60.       end;
  61.     end;
  62.   end;
  63.   sleep(1);
  64. end;
  65. os.pullEvent = oldPull;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement