Advertisement
BlueMond

MCRegisterClient

Sep 5th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.22 KB | None | 0 0
  1. local version = "1.07"  --change this to allow for an update (3 chars only)
  2. local filename = "MCReg"  --change this to the name of the file holding this program
  3. local paste = "RRANf6PW"  --change this to the pastebin entry code
  4.  
  5. local function update()
  6.         local url = "http://pastebin.com/raw/"..paste
  7.         local temp = http.get(url)
  8.         local ver = string.sub(temp.readLine(), 18, 21)
  9.        
  10.         if ver ~= version then
  11.                 fs.delete(filename)
  12.                 shell.run("pastebin get "..paste.." "..filename)
  13.                 shell.run(filename)
  14.                 return true
  15.         end
  16.        
  17.         return false
  18.        
  19. end
  20.  
  21. --start
  22. if update() then
  23.     error()
  24. end
  25. shell.run("clear")
  26.  
  27. --not mine
  28. local function split(str)
  29.     local t = {}  -- NOTE: use {n = 0} in Lua-5.0
  30.     local fpat = "(.-)" .. ":" --character to use
  31.     local last_end = 1
  32.     local s, e, cap = str:find(fpat, 1)
  33.         while s do
  34.             if s ~= 1 or cap ~= "" then
  35.                 table.insert(t,cap)
  36.             end
  37.             last_end = e+1
  38.             s, e, cap = str:find(fpat, last_end)
  39.         end
  40.         if last_end <= #str then
  41.             cap = str:sub(last_end)
  42.             table.insert(t, cap)
  43.         end
  44.     return t
  45. end
  46.  
  47.  
  48. --host protocol for id
  49. --rednet.host("MCAuth","AuthenticationServer")
  50.  
  51. rednet.open("top")
  52.  
  53. shell.run("clear")
  54.  
  55. local name, age, pass, confirm
  56.  
  57. print("~Welcome to MCRegister~\n")
  58. print("This will take your information and upload it to the main network.")
  59.  
  60. term.write("MC Username: ")
  61. name = read()
  62.  
  63. term.write("\nAge: ")
  64. age = read()
  65.  
  66. term.write("\nPassword: ")
  67. pass = read("*")
  68.  
  69. term.write("Retype password: ")
  70. confirm = read("*")
  71.  
  72. shell.run("clear")
  73. if pass == confirm then
  74.     print("Finding Server..")
  75.     local id = rednet.lookup("MCAuth","AuthenticationServer")
  76.    
  77.     if id ~= nil then
  78.         print("Found Server! Sending Data..")
  79.         rednet.send(id, "$REGISTER$:"..name..":"..pass..":"..age)
  80.         print("Waiting for reply..")
  81.        
  82.         local go = true
  83.         while go do
  84.             local rID,msg = rednet.receive()
  85.            
  86.             if rID == id then
  87.                 go = false
  88.                 print(msg)
  89.             end
  90.         end
  91.     else
  92.         print("No Servers Found!")
  93.        
  94.     end
  95. else
  96.     print("Passwords do not match.")
  97.    
  98. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement