Guest User

bankDisks

a guest
May 2nd, 2014
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.70 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2. rednet.open("left")
  3. serverId = 13
  4. while true do
  5.   shell.run("clear")
  6.   print("Enter username:")
  7.   local usr = read()
  8.   if usr == "shutdown" then
  9.     break
  10.   else
  11.     rednet.send(serverId, "create")
  12.     id1,msg = rednet.receive()
  13.     if id1 == serverId then
  14.       if msg == "continue" then
  15.         rednet.send(serverId, usr)
  16.         id,msg = rednet.receive()
  17.         if msg == "continue" then
  18.           print("Enter password:")
  19.           local pwd = read("*")
  20.           rednet.send(serverId, pwd)
  21.           id,msg = rednet.receive()
  22.           if msg == "created" then
  23.             print("Account created")
  24.             while true do
  25.               if disk.hasData("bottom") then
  26.                 local label = disk.getLabel("bottom")
  27.                 if label ~= nil then
  28.                   disk.eject("bottom")
  29.                   os.pullEvent("disk")
  30.                 else
  31.                   disk.setLabel("bottom", usr)
  32.                   disk.eject("bottom")
  33.                   print("Account "..usr.." created")
  34.                   sleep(3)
  35.                   break
  36.                 end
  37.               elseif disk.isPresent("bottom") then
  38.                 disk.eject("bottom")
  39.                 os.pullEvent("disk")
  40.               else
  41.                 print("Please wait for a disk")
  42.                 os.pullEvent("disk")
  43.               end
  44.             end
  45.           else
  46.             print("Error, please try again")
  47.             sleep(3)
  48.           end
  49.         else
  50.           print("Password already in use, please try again")
  51.           sleep(3)
  52.         end
  53.       end      
  54.     else
  55.       print("Could not authenticate server, retry")
  56.       sleep(3)
  57.     end
  58.   end
  59. end
Add Comment
Please, Sign In to add comment